Skip to content

Shell completions

Dominik Gedon edited this page Oct 25, 2021 · 3 revisions

Shell completions

The Cobra library offers a neat built-in command to generate shell completions for bash, fish, powershell and zsh.

How to generate shell completions

The shell completion files can be found unter config/completions/

Makefile

make build does include the creation of the shell completions.

CLI

./cobbler completion -h

Generate the autocompletion script for cobbler for the specified shell.
See each sub-command's help for details on how to use the generated script.

Usage:
  cobbler completion [command]

Available Commands:
  bash        generate the autocompletion script for bash
  fish        generate the autocompletion script for fish
  powershell  generate the autocompletion script for powershell
  zsh         generate the autocompletion script for zsh

If you are in the root folder of the GitHub project, execute the following command to generate the completions for e.g. zsh:

./cobbler completion zsh > config/completions/zsh/cobbler

Check the file afterwards. There could be some debug/error messages in the first few lines from the CLI output itself which have to be removed.

Clone this wiki locally