-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added replay command which replays most recent reply (#21)
Examples: `clai re` `clai -r replay` If you quickly want to check the most recent message or replay some reply without formatting, this is the command for you
- Loading branch information
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package reply | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/baalimago/clai/internal/utils" | ||
) | ||
|
||
func Replay(raw bool) error { | ||
prevReply, err := Load("") | ||
if err != nil { | ||
return fmt.Errorf("failed to load previous reply: %v", err) | ||
} | ||
amMessages := len(prevReply.Messages) | ||
if amMessages == 0 { | ||
return errors.New("failed to find any recent reply") | ||
} | ||
mostRecentMsg := prevReply.Messages[amMessages-1] | ||
utils.AttemptPrettyPrint(mostRecentMsg, "system", raw) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters