cli

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package cli initializes cobra commands by parsing yaml files.

Index

Constants

This section is empty.

Variables

View Source
var CompletionCmd = &cobra.Command{
	Use:   "completion [bash|zsh]",
	Short: "Generate completion script",
	Long: `To load completions:
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 persist completions, execute once:
$ oneterminal completion zsh > "${fpath[1]}/_oneterminal"

Bash:

$ source <(oneterminal completion bash)

# To persist completions, execute once:
Linux:
  $ oneterminal completion bash > /etc/bash_completion.d/oneterminal
MacOS:
  $ oneterminal completion bash > /usr/local/etc/bash_completion.d/oneterminal
`,
	DisableFlagsInUseLine: true,
	ValidArgs:             []string{"bash", "zsh"},
	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)
		}
	},
}

CompletionCmd returns a string that can be piped to add bash/zsh completions

View Source
var ExampleCmd = &cobra.Command{
	Use:   "example",
	Short: "Makes a demo oneterminal config in ~/.config/oneterminal",
	Run: func(cmd *cobra.Command, args []string) {
		if err := yaml.WriteExampleConfig("example.yml"); err != nil {
			panic(fmt.Sprintf("Error generating example config :( %s", err))
		}
		fmt.Println("Example file generated at ~/.config/oneterminal/example.yml")
	},
}

ExampleCmd makes an example oneterminal config file in the ~/.config/oneterminal directory

Functions

func Init added in v0.3.3

func Init(version string) (*cobra.Command, error)

Init creates the root command by parsing all yaml configs from the ~/.config/oneterminal directory and adding them to the root command.

All commands will be accessible via oneterminal <command-name>

Types

This section is empty.

Jump to

Keyboard shortcuts

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