vendor/github.com/spf13/cobra/shell_completions.md
changeset 265 05c40b36d3b2
parent 260 445e01aede7e
equal deleted inserted replaced
264:8f478162d991 265:05c40b36d3b2
    97 To tell Cobra *not* to provide the default `completion` command:
    97 To tell Cobra *not* to provide the default `completion` command:
    98 ```
    98 ```
    99 rootCmd.CompletionOptions.DisableDefaultCmd = true
    99 rootCmd.CompletionOptions.DisableDefaultCmd = true
   100 ```
   100 ```
   101 
   101 
       
   102 To tell Cobra to mark the default `completion` command as *hidden*:
       
   103 ```
       
   104 rootCmd.CompletionOptions.HiddenDefaultCmd = true
       
   105 ```
       
   106 
   102 To tell Cobra *not* to provide the user with the `--no-descriptions` flag to the completion sub-commands:
   107 To tell Cobra *not* to provide the user with the `--no-descriptions` flag to the completion sub-commands:
   103 ```
   108 ```
   104 rootCmd.CompletionOptions.DisableNoDescFlag = true
   109 rootCmd.CompletionOptions.DisableNoDescFlag = true
   105 ```
   110 ```
   106 
   111 
   528 
   533 
   529 # Without descriptions
   534 # Without descriptions
   530 $ helm s[tab]
   535 $ helm s[tab]
   531 search  show  status
   536 search  show  status
   532 ```
   537 ```
       
   538 ### Aliases
       
   539 
       
   540 You can also configure `powershell` aliases for your program and they will also support completions.
       
   541 
       
   542 ```
       
   543 $ sal aliasname origcommand
       
   544 $ Register-ArgumentCompleter -CommandName 'aliasname' -ScriptBlock $__origcommandCompleterBlock
       
   545 
       
   546 # and now when you run `aliasname` completion will make
       
   547 # suggestions as it did for `origcommand`.
       
   548 
       
   549 $ aliasname <tab>
       
   550 completion     firstcommand   secondcommand
       
   551 ```
       
   552 The name of the completer block variable is of the form `$__<programName>CompleterBlock` where every `-` and `:` in the program name have been replaced with `_`, to respect powershell naming syntax.
   533 
   553 
   534 ### Limitations
   554 ### Limitations
   535 
   555 
   536 * Custom completions implemented in bash scripting (legacy) are not supported and will be ignored for `powershell` (including the use of the `BashCompCustom` flag annotation).
   556 * Custom completions implemented in bash scripting (legacy) are not supported and will be ignored for `powershell` (including the use of the `BashCompCustom` flag annotation).
   537   * You should instead use `ValidArgsFunction` and `RegisterFlagCompletionFunc()` which are portable to the different shells (`bash`, `zsh`, `fish`, `powershell`).
   557   * You should instead use `ValidArgsFunction` and `RegisterFlagCompletionFunc()` which are portable to the different shells (`bash`, `zsh`, `fish`, `powershell`).