cmd

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Bash:

  $ source <(yourprogram completion bash)

  # To load completions for each session, execute once:
  # Linux:
  $ yourprogram completion bash > /etc/bash_completion.d/yourprogram
  # macOS:
  $ yourprogram completion bash > /usr/local/etc/bash_completion.d/yourprogram

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:
  $ yourprogram completion zsh > "${fpath[1]}/_yourprogram"

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

fish:

  $ yourprogram completion fish | source

  # To load completions for each session, execute once:
  $ yourprogram completion fish > ~/.config/fish/completions/yourprogram.fish

PowerShell:

  PS> yourprogram completion powershell | Out-String | Invoke-Expression

  # To load completions for every new session, run:
  PS> yourprogram completion powershell > yourprogram.ps1
  # and source this file from your PowerShell profile.
`,
	DisableFlagsInUseLine: true,
	ValidArgs:             []string{"bash", "zsh", "fish", "powershell"},
	Args:                  cobra.ExactValidArgs(1),
	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)
		}
	},
}

CompletionCmd is not really working for now. Would be nice if this actually worked.

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

Types

type ErrorHandler

type ErrorHandler struct {
	// contains filtered or unexported fields
}

ErrorHandler handles errors

func (ErrorHandler) HandleError

func (eh ErrorHandler) HandleError(step string, err error)

HandleError handles the given error

func (ErrorHandler) HandleErrorWithOutput added in v0.1.9

func (eh ErrorHandler) HandleErrorWithOutput(step string, err error, output string)

HandleErrorWithOutput handles the given error and prints output

func (ErrorHandler) PrintError added in v0.1.7

func (eh ErrorHandler) PrintError(step string, err error)

PrintError prints the error, no exit

func (ErrorHandler) PrintErrorWithOutput added in v0.1.9

func (eh ErrorHandler) PrintErrorWithOutput(step string, err error, output string)

PrintErrorWithOutput prints the given error and output

type SemanticVersion added in v0.1.7

type SemanticVersion struct {
	Major int
	Minor int
	Patch int
}

SemanticVersion is a struct for semantic version

func NewSemanticVersion added in v0.1.7

func NewSemanticVersion(version string) (SemanticVersion, error)

NewSemanticVersion creates a new instance of semantic version

func (SemanticVersion) String added in v0.1.7

func (sv SemanticVersion) String() string

Jump to

Keyboard shortcuts

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