Add --count flag to list command, lower default from 25 to 5

This commit is contained in:
Matt Low 2024-02-22 05:02:08 +00:00
parent 120e61e88b
commit 2611663168

View File

@ -19,7 +19,7 @@ var (
const (
// Limit number of conversations shown with `ls`, without --all
LS_LIMIT int = 25
LS_LIMIT int = 5
)
func init() {
@ -32,7 +32,9 @@ func init() {
cmd.MarkFlagsMutuallyExclusive("system-prompt", "system-prompt-file")
}
listCmd.Flags().Bool("all", false, fmt.Sprintf("Show all conversations, by default only the last %d are shown", LS_LIMIT))
listCmd.Flags().Int("count", LS_LIMIT, fmt.Sprintf("Number of conversations to list"))
listCmd.Flags().Bool("all", false, "List all conversations")
renameCmd.Flags().Bool("generate", false, "Generate a conversation title")
editCmd.Flags().Int("offset", 1, "Offset from the last reply to edit (Default: edit your last message, assuming there's an assistant reply)")
@ -225,6 +227,7 @@ var listCmd = &cobra.Command{
categorized := map[string][]ConversationLine{}
all, _ := cmd.Flags().GetBool("all")
count, _ := cmd.Flags().GetInt("count")
for _, conversation := range conversations {
lastMessage, err := store.LastMessage(&conversation)
@ -269,7 +272,7 @@ var listCmd = &cobra.Command{
fmt.Printf("%s:\n", category.name)
for _, conv := range conversationLines {
if conversationsPrinted >= LS_LIMIT && !all {
if conversationsPrinted >= count && !all {
fmt.Printf("%d remaining message(s), use --all to view.\n", len(conversations)-conversationsPrinted)
break outer
}