diff options
| author | Paul Buetow <paul@buetow.org> | 2024-07-28 23:11:17 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-07-28 23:11:17 +0300 |
| commit | d1a76d38823e2ada4eb30e175a17471550017900 (patch) | |
| tree | f681eb0850fe133a8633dc7531792da621d9521f /internal/client/tui/submit.go | |
| parent | c4454028242e384927d74bf32ae6230be52f8119 (diff) | |
refactor
Diffstat (limited to 'internal/client/tui/submit.go')
| -rw-r--r-- | internal/client/tui/submit.go | 10 |
1 files changed, 5 insertions, 5 deletions
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...)) } |
