cmd

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: Apache-2.0 Imports: 9 Imported by: 7

README

Cobra Command Wrapper

Test Coverall Report Doc License

What does it do?

A wrapper to help to create Cobra CLI applications.

Improvements to be made

  • 100% test coverage.
  • Better covering for other features.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFormatter added in v0.2.0

func CreateFormatter(logFormat string) logrus.Formatter

CreateFormatter create logrus formatter by string.

Types

type Commander

type Commander struct {
	Root   *cobra.Command
	Config *Config
}

Commander is a struct for command system.

func NewCommander

func NewCommander(cmd *cobra.Command) *Commander

NewCommander is a factory for Commander.

func (*Commander) Execute

func (c *Commander) Execute() error

Execute executes Cobra commands.

func (*Commander) Init

func (c *Commander) Init() *Commander

Init is entrypoint for the commands.

func (*Commander) SetCommand

func (c *Commander) SetCommand(cmds ...*cobra.Command) *Commander

SetCommand sets Root command.

func (*Commander) SetConfig added in v0.4.0

func (c *Commander) SetConfig(config *Config) *Commander

SetConfig sets Config for Commander.

func (*Commander) SetPersistentFlags

func (c *Commander) SetPersistentFlags(p func(c *Commander)) *Commander

SetPersistentFlags sets persistent flags.

type Config added in v0.4.0

type Config struct {
	Name              *string
	Path              *string
	EnvironmentPrefix *string
}

Config is a struct for CLI configuration.

func (*Config) Init added in v0.4.0

func (c *Config) Init() *Config

Init inits Config.

Jump to

Keyboard shortcuts

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