Skip to content

Commit

Permalink
fix: improve --continue (#159)
Browse files Browse the repository at this point in the history
* fix: improve --continue

If you run `mods` without any args or input, it'll print the help.
If you run `mods` with either a prompt or piping something from stdin,
it uses that as a prompt.

`mods -C` was requiring a prompt even when it was provided via stdin.
This removes that check, so it works the same as `mods` without the `-C`
flag now.

closes #132

* test: update

Signed-off-by: Carlos Alexandro Becker <[email protected]>

---------

Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 authored Nov 16, 2023
1 parent d0d321d commit 5037453
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
7 changes: 0 additions & 7 deletions mods.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,13 +505,6 @@ func (m *Mods) findCacheOpsDetails() tea.Cmd {
writeID := ordered.First(m.Config.Title, m.Config.Continue)
title := writeID

if continueLast && m.Config.Prefix == "" {
return modsError{
err: fmt.Errorf("Missing prompt"),
reason: "You must specify a prompt.",
}
}

if readID != "" || continueLast || m.Config.ShowLast {
found, err := m.findReadID(readID)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions mods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ func TestFindCacheOpsDetails(t *testing.T) {
require.NoError(t, mods.db.Save(id, "message 1"))
mods.Config.ContinueLast = true
msg := mods.findCacheOpsDetails()()
err := msg.(modsError)
require.Error(t, err.err)
require.Equal(t, "You must specify a prompt.", err.reason)
dets := msg.(cacheDetailsMsg)
require.Equal(t, id, dets.ReadID)
require.Equal(t, id, dets.WriteID)
require.Empty(t, dets.Title)
})

t.Run("continue title", func(t *testing.T) {
Expand Down

0 comments on commit 5037453

Please sign in to comment.