goctl completion

Overview

goctl uses Cobra framework development, so it inherits Cobra auto completion, in goctl, They provide the auto-completion features of cash,fish,zshandpowershell.

goctl completion directive

  1. $ goctl completion --help
  2. Generate the autocompletion script for goctl for the specified shell.
  3. See each sub-command's help for details on how to use the generated script.
  4. Usage:
  5. goctl completion [command]
  6. Available Commands:
  7. bash Generate the autocompletion script for bash
  8. fish Generate the autocompletion script for fish
  9. powershell Generate the autocompletion script for powershell
  10. zsh Generate the autocompletion script for zsh
  11. Flags:
  12. -h, --help help for completion
  13. Use "goctl completion [command] --help" for more information about a command.

Currently goctl supports cash,fish,zshandpower shell if you are Windows operating system and use powershell, You can choose goctl complete power shell to generate scripts. If you are Linux or Mac operating systems, you can choose to create scripts other than goctl complete power shell but only by your current shell.

goctl completion - 图1for the current shell

in Linux or Mac operating systems, see the current shell, by echo $SHELL Effect is zsh, then select goctl completion zsh to generate script, The result is cash, select goctl completion cash to generate the script, The result is fish, select goctl complete fish to generate scripts.

goctl completion bash directive

  1. $ goctl completion bash --help
  2. Generate the autocompletion script for the bash shell.
  3. This script depends on the 'bash-completion' package.
  4. If it is not installed already, you can install it via your OS's package manager.
  5. To load completions in your current shell session:
  6. source <(goctl completion bash)
  7. To load completions for every new session, execute once:
  8. #### Linux:
  9. goctl completion bash > /etc/bash_completion.d/goctl
  10. #### macOS:
  11. goctl completion bash > $(brew --prefix)/etc/bash_completion.d/goctl
  12. You will need to start a new shell for this setup to take effect.
  13. Usage:
  14. goctl completion bash
  15. Flags:
  16. -h, --help help for bash
  17. --no-descriptions disable completion descriptions

In Linux or Mac operating systems, if you are using cashyou can generate scripts by goctl completion bash , note that,goctl completion bash dependency bash-completion package support, if your operating system is not installed, it is recommended to install it yourself.

1 Temporary entry into force

Temporary entry is only useful for the current terminal session and is one-time in nature.

  1. $ source <(goctl completion bash)

2 Permanent entry into force

Permanently effective settings differ according to operating system and their setup method, need to restart terminals to take effect after setup. Currently settings for Linux and MacOS are set below:

  • Linux
  • MacOS
  1. $ goctl completion bash > /etc/bash_completion.d/goctl
  1. $ goctl completion bash > $(brew --prefix)/etc/bash_completion.d/goctl

goctl completion fish directive

  1. $ goctl completion fish --help
  2. Generate the autocompletion script for the fish shell.
  3. To load completions in your current shell session:
  4. goctl completion fish | source
  5. To load completions for every new session, execute once:
  6. goctl completion fish > ~/.config/fish/completions/goctl.fish
  7. You will need to start a new shell for this setup to take effect.
  8. Usage:
  9. goctl completion fish [flags]
  10. Flags:
  11. -h, --help help for fish
  12. --no-descriptions disable completion descriptions

1 Temporary entry into force

Temporary entry is only useful for the current terminal session and is one-time in nature.

  1. $ goctl completion fish | source

2 Permanent entry into force

  1. $ goctl completion fish > ~/.config/fish/completions/goctl.fish

goctl completion powershell directive

  1. $ goctl completion powershell --help
  2. Generate the autocompletion script for powershell.
  3. To load completions in your current shell session:
  4. goctl completion powershell | Out-String | Invoke-Expression
  5. To load completions for every new session, add the output of the above command
  6. to your powershell profile.
  7. Usage:
  8. goctl completion powershell [flags]
  9. Flags:
  10. -h, --help help for powershell
  11. --no-descriptions disable completion descriptions

1 Temporary entry into force

Temporary entry is only useful for the current terminal session and is one-time in nature.

  1. $ goctl completion powershell | Out-String | Invoke-Expression

2 Permanent entry into force

The following output needs to be added to the power shell’s profile.

  1. $ goctl completion powershell | Out-String | Invoke-Expression

goctl completion zsh directive

  1. $ goctl completion zsh --help
  2. Generate the autocompletion script for the zsh shell.
  3. If shell completion is not already enabled in your environment you will need
  4. to enable it. You can execute the following once:
  5. echo "autoload -U compinit; compinit" >> ~/.zshrc
  6. To load completions in your current shell session:
  7. source <(goctl completion zsh); compdef _goctl goctl
  8. To load completions for every new session, execute once:
  9. #### Linux:
  10. goctl completion zsh > "${fpath[1]}/_goctl"
  11. #### macOS:
  12. goctl completion zsh > $(brew --prefix)/share/zsh/site-functions/_goctl
  13. You will need to start a new shell for this setup to take effect.
  14. Usage:
  15. goctl completion zsh [flags]
  16. Flags:
  17. -h, --help help for zsh
  18. --no-descriptions disable completion descriptions

::tip hint If you are using zsh, and shell completion is not enabled, you can enable: by following instructions

  1. echo "autoload -U compinit; compinit" >> ~/.zshrc

:::

1 Temporary entry into force

Temporary entry is only useful for the current terminal session and is one-time in nature.

  1. $ source <(goctl completion zsh); compdef _goctl goctl

2 Permanent entry into force

Permanently effective settings differ according to operating system and their setup method, need to restart terminals to take effect after setup. Currently settings for Linux and MacOS are set below:

  • Linux
  • MacOS
  1. $ goctl completion zsh > "${fpath[1]}/_goctl"
  1. $ goctl completion zsh > $(brew --prefix)/share/zsh/site-functions/_goctl