1
0
Fork 0
mirror of https://github.com/spf13/cobra synced 2025-04-12 01:37:19 +00:00

Improve documentation of DefaultShellCompDirective

This commit is contained in:
Harald Albers 2025-03-06 12:26:08 +00:00
parent 84a1965f14
commit 6ad4cd6904

View file

@ -319,7 +319,7 @@ cmd.RegisterFlagCompletionFunc("flag-name", cobra.NoFileCompletions)
```
If you find that there are more situations where file completion should be turned off than
when it is applicable, you can change the default `ShellCompDirective` for a command
when it is applicable, you can recursively change the default `ShellCompDirective` for a command
and its subcommands to `ShellCompDirectiveNoFileComp`:
```go
@ -333,6 +333,8 @@ flags where file completion is applicable. For example:
cmd.RegisterFlagCompletionFunc("flag-name", cobra.FixedCompletions(nil, ShellCompDirectiveDefault))
```
To change the default directive for the entire program, set the DefaultShellCompDirective on the root command.
#### Debugging
You can also easily debug your Go completion code for flags: