summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--add.go8
-rw-r--r--main.go4
2 files changed, 10 insertions, 2 deletions
diff --git a/add.go b/add.go
index 2b358fe..67427df 100644
--- a/add.go
+++ b/add.go
@@ -3,6 +3,7 @@ package main
import (
"bytes"
"encoding/json"
+ "errors"
"fmt"
"io"
"net/http"
@@ -42,6 +43,13 @@ type options struct {
func addCard(c *http.Client, front, back string) tea.Cmd {
return func() tea.Msg {
+ if back == "" {
+ return errMsg(errors.New("definition is blank"))
+ }
+ if front == "" {
+ return errMsg(errors.New("word is blank"))
+ }
+
noteRequest := addNote{
Action: "addNote",
Version: apiVersion,
diff --git a/main.go b/main.go
index f1a4076..d5900b7 100644
--- a/main.go
+++ b/main.go
@@ -135,11 +135,11 @@ var whitespaceTrimmerRe = regexp.MustCompile(`^[ \t]*$`)
func (m model) View() string {
return fmt.Sprintf(
- "Look up a word:\n\n%s\n\nStatus: %s\n\n%s\n\n%s\n%s",
+ "\x1b[1;30;42mLook up a word:\x1b[0m\n\n%s\n\n\x1b[1;30;42mStatus:\x1b[0m %s\n\n%s\n\n%s\n%s",
m.wordInput.View(),
formatStatus(m.err, m.wordAddStatus),
"(ctrl-c to quit, esc to clear, enter to add to Anki)",
- "Current definition:\n",
+ "\x1b[1;30;42mCurrent definition:\x1b[0m\n",
m.vp.View(),
) + "\n"
}