cobra

package
v0.0.0-...-9823ec8 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package cobra defines the cobra command structs and an execution method for adding an improved CLI to Sonic based API Gateways

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultRoot  Root
	RootCommand  Command
	RunCommand   Command
	CheckCommand Command
)

Functions

func Execute

func Execute(configParser config.Parser, f Executor)

func ExecuteRoot

func ExecuteRoot(configParser config.Parser, f Executor, root Root)

func GetConfigFlag

func GetConfigFlag() string

func GetDebugFlag

func GetDebugFlag() bool

Types

type Command

type Command struct {
	Cmd   *cobra.Command
	Flags []FlagBuilder
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(command *cobra.Command, flags ...FlagBuilder) Command

func (*Command) AddFlag

func (c *Command) AddFlag(f FlagBuilder)

func (*Command) AddSubCommand

func (c *Command) AddSubCommand(cmd *cobra.Command)

func (*Command) BuildFlags

func (c *Command) BuildFlags()

type Executor

type Executor func(config.ServiceConfig)

type FlagBuilder

type FlagBuilder func(*cobra.Command)

func BoolFlagBuilder

func BoolFlagBuilder(dst *bool, long, short string, defaultValue bool, help string) FlagBuilder

func CountFlagBuilder

func CountFlagBuilder(dst *int, long, short string, help string) FlagBuilder

func DurationFlagBuilder

func DurationFlagBuilder(dst *time.Duration, long, short string, defaultValue time.Duration, help string) FlagBuilder

func Float64FlagBuilder

func Float64FlagBuilder(dst *float64, long, short string, defaultValue float64, help string) FlagBuilder

func IntFlagBuilder

func IntFlagBuilder(dst *int, long, short string, defaultValue int, help string) FlagBuilder

func StringFlagBuilder

func StringFlagBuilder(dst *string, long, short, defaultValue, help string) FlagBuilder

type Root

type Root struct {
	Command
	SubCommands []Command
	// contains filtered or unexported fields
}

func NewRoot

func NewRoot(root Command, subCommands ...Command) Root

func (*Root) Build

func (r *Root) Build()

func (Root) Execute

func (r Root) Execute(configParser config.Parser, f Executor)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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