Disable autocompletion entirely when its not required

This commit is contained in:
jbogusz-billtech 2023-12-28 20:51:33 +01:00
parent 90ac9d379a
commit e919673201

View File

@ -1231,7 +1231,7 @@ func completionHandler(cmd *cobra.Command, args []string) error {
case "fish":
err = cmd.Root().GenFishCompletion(os.Stdout, true)
default:
err = errors.New("unsupported shell")
err = errors.New("unsupported shell. Supported shells: zsh, fish, bash")
}
if err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err)
@ -1317,6 +1317,7 @@ func NewCLI() *cobra.Command {
Args: cobra.ExactArgs(1),
PreRunE: checkServerHeartbeat,
RunE: CreateHandler,
ValidArgsFunction: doNotAutocomplete,
}
createCmd.Flags().StringP("file", "f", "Modelfile", "Name of the Modelfile (default \"Modelfile\")")
@ -1356,6 +1357,7 @@ func NewCLI() *cobra.Command {
Short: "Start ollama",
Args: cobra.ExactArgs(0),
RunE: RunServer,
ValidArgsFunction: doNotAutocomplete,
}
pullCmd := &cobra.Command{
@ -1386,6 +1388,7 @@ func NewCLI() *cobra.Command {
Short: "List models",
PreRunE: checkServerHeartbeat,
RunE: ListHandler,
ValidArgsFunction: doNotAutocomplete,
}
copyCmd := &cobra.Command{
@ -1413,6 +1416,9 @@ func NewCLI() *cobra.Command {
Hidden: true,
Args: cobra.ExactArgs(1),
RunE: completionHandler,
ValidArgsFunction: func(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return []string{"bash", "zsh", "fish"}, cobra.ShellCompDirectiveNoFileComp
},
}
rootCmd.AddCommand(