Fixed `lmcli view` completions

- Don't return completions if an arg is already present
- Fixed typo in method name
This commit is contained in:
Matt Low 2023-11-13 05:26:21 +00:00
parent 4e3976fc73
commit b0e4739f4f
2 changed files with 6 additions and 2 deletions

View File

@ -140,7 +140,11 @@ var viewCmd = &cobra.Command{
fmt.Println() fmt.Println()
}, },
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return store.ConverstionShortNameCompletions(toComplete), cobra.ShellCompDirectiveNoFileComp compMode := cobra.ShellCompDirectiveNoFileComp
if len(args) != 0 {
return nil, compMode
}
return store.ConversationShortNameCompletions(toComplete), compMode
}, },
} }

View File

@ -96,7 +96,7 @@ func (s *Store) Conversations() ([]Conversation, error) {
return conversations, err return conversations, err
} }
func (s *Store) ConverstionShortNameCompletions(shortName string) []string { func (s *Store) ConversationShortNameCompletions(shortName string) []string {
var completions []string var completions []string
conversations, _ := s.Conversations() // ignore error for completions conversations, _ := s.Conversations() // ignore error for completions
for _, conversation := range conversations { for _, conversation := range conversations {