completion

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CobraCompletionCmd = &cobra.Command{
	Use:   "completion [bash|zsh|fish|powershell]",
	Short: "Generate completion script",
	Long: `To load completions:

Bash:

	source <({{.Use}} completion bash)
	
	# To load completions for each session, execute once:
	# Linux:
	{{.Use}} completion bash > /etc/bash_completion.d/{{.Use}}
	# macOS:
	{{.Use}} completion bash > /usr/local/etc/bash_completion.d/{{.Use}}

Zsh:

	# If shell completion is not already enabled in your environment,
	# you will need to enable it.  You can execute the following once:
	echo "autoload -U compinit; compinit" >> ~/.zshrc

	# To load completions for each session, execute once:
	{{.Use}} completion zsh > "${fpath[1]}/_{{.Use}}"

	# You will need to start a new shell for this setup to take effect.

fish:

	{{.Use}} completion fish | source
	
	# To load completions for each session, execute once:
	{{.Use}} completion fish > ~/.config/fish/completions/{{.Use}}.fish

PowerShell:

	{{.Use}} completion powershell | Out-String | Invoke-Expression
	
	# To load completions for every new session, run:
	{{.Use}} completion powershell > {{.Use}}.ps1
	# and source this file from your PowerShell profile.
`,
	DisableFlagsInUseLine: true,
	ValidArgs:             []string{"bash", "zsh", "fish", "powershell"},
	Args:                  cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
	Run: func(cmd *cobra.Command, args []string) {
		switch args[0] {
		case "bash":
			cmd.Root().GenBashCompletion(os.Stdout)
		case "zsh":
			cmd.Root().GenZshCompletion(os.Stdout)
		case "fish":
			cmd.Root().GenFishCompletion(os.Stdout, true)
		case "powershell":
			cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
		}
	},
}

CobraCompletionCmd represents the completion command

Functions

func AddToRootCmd

func AddToRootCmd(rootCmd *cobra.Command)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL