Disable autocompletion entirely when its not required
This commit is contained in:
parent
90ac9d379a
commit
e919673201
38
cmd/cmd.go
38
cmd/cmd.go
@ -1231,7 +1231,7 @@ func completionHandler(cmd *cobra.Command, args []string) error {
|
|||||||
case "fish":
|
case "fish":
|
||||||
err = cmd.Root().GenFishCompletion(os.Stdout, true)
|
err = cmd.Root().GenFishCompletion(os.Stdout, true)
|
||||||
default:
|
default:
|
||||||
err = errors.New("unsupported shell")
|
err = errors.New("unsupported shell. Supported shells: zsh, fish, bash")
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error: %s\n", err)
|
fmt.Fprintf(os.Stderr, "error: %s\n", err)
|
||||||
@ -1312,11 +1312,12 @@ func NewCLI() *cobra.Command {
|
|||||||
rootCmd.Flags().BoolP("version", "v", false, "Show version information")
|
rootCmd.Flags().BoolP("version", "v", false, "Show version information")
|
||||||
|
|
||||||
createCmd := &cobra.Command{
|
createCmd := &cobra.Command{
|
||||||
Use: "create MODEL",
|
Use: "create MODEL",
|
||||||
Short: "Create a model from a Modelfile",
|
Short: "Create a model from a Modelfile",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
PreRunE: checkServerHeartbeat,
|
PreRunE: checkServerHeartbeat,
|
||||||
RunE: CreateHandler,
|
RunE: CreateHandler,
|
||||||
|
ValidArgsFunction: doNotAutocomplete,
|
||||||
}
|
}
|
||||||
|
|
||||||
createCmd.Flags().StringP("file", "f", "Modelfile", "Name of the Modelfile (default \"Modelfile\")")
|
createCmd.Flags().StringP("file", "f", "Modelfile", "Name of the Modelfile (default \"Modelfile\")")
|
||||||
@ -1351,11 +1352,12 @@ func NewCLI() *cobra.Command {
|
|||||||
runCmd.Flags().String("format", "", "Response format (e.g. json)")
|
runCmd.Flags().String("format", "", "Response format (e.g. json)")
|
||||||
|
|
||||||
serveCmd := &cobra.Command{
|
serveCmd := &cobra.Command{
|
||||||
Use: "serve",
|
Use: "serve",
|
||||||
Aliases: []string{"start"},
|
Aliases: []string{"start"},
|
||||||
Short: "Start ollama",
|
Short: "Start ollama",
|
||||||
Args: cobra.ExactArgs(0),
|
Args: cobra.ExactArgs(0),
|
||||||
RunE: RunServer,
|
RunE: RunServer,
|
||||||
|
ValidArgsFunction: doNotAutocomplete,
|
||||||
}
|
}
|
||||||
|
|
||||||
pullCmd := &cobra.Command{
|
pullCmd := &cobra.Command{
|
||||||
@ -1381,11 +1383,12 @@ func NewCLI() *cobra.Command {
|
|||||||
pushCmd.Flags().Bool("insecure", false, "Use an insecure registry")
|
pushCmd.Flags().Bool("insecure", false, "Use an insecure registry")
|
||||||
|
|
||||||
listCmd := &cobra.Command{
|
listCmd := &cobra.Command{
|
||||||
Use: "list",
|
Use: "list",
|
||||||
Aliases: []string{"ls"},
|
Aliases: []string{"ls"},
|
||||||
Short: "List models",
|
Short: "List models",
|
||||||
PreRunE: checkServerHeartbeat,
|
PreRunE: checkServerHeartbeat,
|
||||||
RunE: ListHandler,
|
RunE: ListHandler,
|
||||||
|
ValidArgsFunction: doNotAutocomplete,
|
||||||
}
|
}
|
||||||
|
|
||||||
copyCmd := &cobra.Command{
|
copyCmd := &cobra.Command{
|
||||||
@ -1413,6 +1416,9 @@ func NewCLI() *cobra.Command {
|
|||||||
Hidden: true,
|
Hidden: true,
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: completionHandler,
|
RunE: completionHandler,
|
||||||
|
ValidArgsFunction: func(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
|
return []string{"bash", "zsh", "fish"}, cobra.ShellCompDirectiveNoFileComp
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user