cli

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2022 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	*cobra.Command
	// contains filtered or unexported fields
}

Command is the main struct which comes from cobar

func New

func New(opts ...Option) *Command

New returns a command with options

func (*Command) InitFlags added in v0.2.8

func (c *Command) InitFlags()

InitFlags init flags from config

func (*Command) IsRoot added in v0.2.0

func (c *Command) IsRoot() bool

IsRoot check if the command is the root

func (*Command) Option added in v0.2.4

func (c *Command) Option(opts ...Option) *Command

Option merge options after new

func (*Command) Register

func (c *Command) Register(scs ...*Command) error

Register create a sub command

func (*Command) Run

func (c *Command) Run(opts ...Option) error

Run execute the whole commands

type ConfigOption added in v0.2.0

type ConfigOption func(co *configOptions)

ConfigOption defined config option for cli

func WithAutoFlags added in v0.3.24

func WithAutoFlags(v bool) ConfigOption

WithAutoFlags set auto register flags

func WithConfigChanged added in v0.2.1

func WithConfigChanged(f func(o, n interface{})) ConfigOption

WithConfigChanged set a watcher to watch the config changed params's type can be auto set with interface{}

func WithConfigName added in v0.2.0

func WithConfigName(names ...string) ConfigOption

WithConfigName set config name

type Option

type Option func(c *Command)

Option set the command with value

func Config added in v0.0.8

func Config(v interface{}) Option

Config loads configuration from provider

func Description

func Description(desc string) Option

Description returns option to set descrtiption

func Example added in v0.0.4

func Example(ex string) Option

Example returns option to set example

func GlobalConfig added in v0.0.10

func GlobalConfig(v interface{}, cfos ...ConfigOption) Option

GlobalConfig ...

func Long

func Long(desc string) Option

Long returns option to set the long

func Name

func Name(names ...string) Option

Name returns option to set use

func PersistentPreRun added in v0.0.10

func PersistentPreRun(fn func(cmd *Command, args ...string)) Option

PersistentPreRun children of this command will inherit and execute.

func PreParseConfig added in v0.2.8

func PreParseConfig() Option

PreParseConfig is a option parse config

func PreRun added in v0.0.10

func PreRun(fn func(cmd *Command, args ...string)) Option

PreRun children of this command will not inherit.

func Run

func Run(fn func(cmd *Command, args ...string)) Option

Run returns option to set the main run function

func SetFlags added in v0.0.4

func SetFlags(setflag func(c *Command)) Option

SetFlags ...

func Short

func Short(desc string) Option

Short returns option to set the short

func Version

func Version(v string) Option

Version returns option to set set the version

Directories

Path Synopsis
Package config provider load configuration from file
Package config provider load configuration from file

Jump to

Keyboard shortcuts

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