summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-07-28 23:11:17 +0300
committerPaul Buetow <paul@buetow.org>2024-07-28 23:11:17 +0300
commitd1a76d38823e2ada4eb30e175a17471550017900 (patch)
treef681eb0850fe133a8633dc7531792da621d9521f
parentc4454028242e384927d74bf32ae6230be52f8119 (diff)
refactor
-rw-r--r--internal/client/tui/compose.go4
-rw-r--r--internal/client/tui/finishedmsg.go6
-rw-r--r--internal/client/tui/submit.go10
-rw-r--r--internal/client/tui/tui.go2
4 files changed, 11 insertions, 11 deletions
diff --git a/internal/client/tui/compose.go b/internal/client/tui/compose.go
index 3148b2a..4672462 100644
--- a/internal/client/tui/compose.go
+++ b/internal/client/tui/compose.go
@@ -28,10 +28,10 @@ func composeAction(conf config.ClientConfig, queue bool) tea.Cmd {
})
}
-func openEditor(editor, filePath string, callback func() error) tea.Cmd {
+func openEditor(editor, filePath string, cb func() error) tea.Cmd {
return tea.ExecProcess(exec.Command(editor, filePath), func(err error) tea.Msg {
return finishedMsg{
- callback: callback,
+ cb: cb,
err: err,
}
})
diff --git a/internal/client/tui/finishedmsg.go b/internal/client/tui/finishedmsg.go
index 6f702f3..c475ce7 100644
--- a/internal/client/tui/finishedmsg.go
+++ b/internal/client/tui/finishedmsg.go
@@ -3,7 +3,7 @@ package tui
import tea "github.com/charmbracelet/bubbletea"
type finishedMsg struct {
- callback func() error
+ cb func() error
err error
}
@@ -11,10 +11,10 @@ func (f finishedMsg) Error() string {
return f.err.Error()
}
-func finished(callback func() error, err error) tea.Cmd {
+func finished(cb func() error, err error) tea.Cmd {
return func() tea.Msg {
return finishedMsg{
- callback: callback,
+ cb: cb,
err: err,
}
}
diff --git a/internal/client/tui/submit.go b/internal/client/tui/submit.go
index 3d908a0..574fb54 100644
--- a/internal/client/tui/submit.go
+++ b/internal/client/tui/submit.go
@@ -17,23 +17,23 @@ func submitAction(ctx context.Context, conf config.ClientConfig) tea.Cmd {
composeFile := fmt.Sprintf("%s/%s", conf.DataDir, conf.ComposeFile)
return submitEntry(ctx, conf, composeFile, func() error {
- // This is the callback to call when the entry was submitted succesfully
+ // This is the cb to call when the entry was submitted succesfully
timestamp := time.Now().Format("20060102-150405")
submittedFile := fmt.Sprintf("%s/submitted-%s.txt", conf.DataDir, timestamp)
return os.Rename(composeFile, submittedFile)
})
}
-func submitEntry(ctx context.Context, conf client.ClientConfig, filePath string, callback func() error) tea.Cmd {
+func submitEntry(ctx context.Context, conf client.ClientConfig, filePath string, cb func() error) tea.Cmd {
servers, err := conf.Servers()
if err != nil {
- return finished(callback, err)
+ return finished(cb, err)
}
ent, err := types.NewEntryFromTextFile(filePath)
if err != nil {
- return finished(callback, err)
+ return finished(cb, err)
}
- return finished(callback, easyhttp.PostData(ctx, "submit", conf.APIKey, &ent, servers...))
+ return finished(cb, easyhttp.PostData(ctx, "submit", conf.APIKey, &ent, servers...))
}
diff --git a/internal/client/tui/tui.go b/internal/client/tui/tui.go
index 8d4c176..2f02910 100644
--- a/internal/client/tui/tui.go
+++ b/internal/client/tui/tui.go
@@ -104,7 +104,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if m.err != nil {
return m, nil
}
- if err := msg.callback(); err != nil {
+ if err := msg.cb(); err != nil {
m.err = err
}
}