mirror of
https://github.com/spf13/cobra
synced 2025-04-27 00:57:23 +00:00
Improve documentation of DefaultShellCompDirective
This commit is contained in:
parent
84a1965f14
commit
6ad4cd6904
1 changed files with 3 additions and 1 deletions
|
@ -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
|
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`:
|
and its subcommands to `ShellCompDirectiveNoFileComp`:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
|
@ -333,6 +333,8 @@ flags where file completion is applicable. For example:
|
||||||
cmd.RegisterFlagCompletionFunc("flag-name", cobra.FixedCompletions(nil, ShellCompDirectiveDefault))
|
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
|
#### Debugging
|
||||||
|
|
||||||
You can also easily debug your Go completion code for flags:
|
You can also easily debug your Go completion code for flags:
|
||||||
|
|
Loading…
Add table
Reference in a new issue