From 6ad4cd6904cb4ea79cced0ae5a6298721258a73d Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Thu, 6 Mar 2025 12:26:08 +0000 Subject: [PATCH] Improve documentation of DefaultShellCompDirective --- site/content/completions/_index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/site/content/completions/_index.md b/site/content/completions/_index.md index 2595a178..0115910f 100644 --- a/site/content/completions/_index.md +++ b/site/content/completions/_index.md @@ -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: