cli

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

命令行补全 版本查看

命令行提示

Index

Constants

This section is empty.

Variables

View Source
var CompletionCmd = &cobra.Command{
	Use:   "completion",
	Short: "生成命令行补全脚本",
	Long:  fmt.Sprintf("source <(%s completion)", appName),
	Run: func(cmd *cobra.Command, args []string) {
		_ = cmd.GenBashCompletion(os.Stdout)
	},
}
View Source
var VersionCmd = &cobra.Command{
	Use:     "version",
	Aliases: []string{"v"},
	Short:   "查看版本",
	Long:    "查看版本",
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Printf("%s\nversion: %s\nbuild: %s\ncommit: %s\n", appName, version, buildTime, gitCommit)
	},
}

Functions

This section is empty.

Types

type Action

type Action struct {
	Suggest   prompt.Suggest
	Executor  ExecutorHandler
	Completer CompleterHandler
	// contains filtered or unexported fields
}

func (*Action) AddSubAction

func (a *Action) AddSubAction(actions ...*Action)

type CompleterHandler

type CompleterHandler func() ([]prompt.Suggest, bool)

type ExecutorHandler

type ExecutorHandler func([]string)

type Prompt

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

func NewPrompt

func NewPrompt() *Prompt

func (*Prompt) Complete

func (p *Prompt) Complete(d prompt.Document) []prompt.Suggest

func (*Prompt) Execute

func (p *Prompt) Execute(in string)

func (*Prompt) RegisterAction

func (p *Prompt) RegisterAction(actions ...*Action)

Jump to

Keyboard shortcuts

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