commands

package
v2.4.0-alpha+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2019 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RootName defines default name used for the root command.
	RootName = "agentctl"
)

Functions

func AddBaseCommands

func AddBaseCommands(cmd *cobra.Command, cli cli.Cli)

AddBaseCommands adds all base commands to cmd.

func DisableFlagsInUseLine

func DisableFlagsInUseLine(cmd *cobra.Command)

DisableFlagsInUseLine sets the DisableFlagsInUseLine flag on all commands within the tree rooted at cmd.

func ExitCode

func ExitCode(err error) int

ExitCode returns proper exit code for err or 0 if err is nil.

func FlagErrorFunc

func FlagErrorFunc(cmd *cobra.Command, err error) error

FlagErrorFunc returns status error when err is not nil. It includes usage string and error message.

func NewAgentCli

func NewAgentCli(opts ...cli.AgentCliOption) *cli.AgentCli

NewAgentCli creates new AgentCli with opts and configures log output to error stream.

func NewDumpCommand

func NewDumpCommand(cli agentcli.Cli) *cobra.Command

func NewGenerateCommand

func NewGenerateCommand(cli agentcli.Cli) *cobra.Command

func NewImportCommand

func NewImportCommand(cli agentcli.Cli) *cobra.Command

func NewKvdbCommand

func NewKvdbCommand(cli agentcli.Cli) *cobra.Command

func NewLogCommand

func NewLogCommand(cli agentcli.Cli) *cobra.Command

func NewModelCommand

func NewModelCommand(cli agentcli.Cli) *cobra.Command

func NewRootCommand

func NewRootCommand(agentCli *cli.AgentCli) (*cobra.Command, error)

NewRootCommand is helper for default initialization process for root command. Returs cobra command which is ready to be executed.

func NewStatusCommand

func NewStatusCommand(cli agentcli.Cli) *cobra.Command

func NewValuesCommand

func NewValuesCommand(cli agentcli.Cli) *cobra.Command

func NewVppCommand

func NewVppCommand(cli agentcli.Cli) *cobra.Command

func RunImport

func RunImport(cli agentcli.Cli, opts ImportOptions) error

func RunLogList

func RunLogList(cli agentcli.Cli, opts LogListOptions) error

func RunLogSet

func RunLogSet(cli agentcli.Cli, opts LogSetOptions) error

func SetupRootCommand

func SetupRootCommand(rootCmd *cobra.Command) (*cli.ClientOptions, *pflag.FlagSet, *cobra.Command)

SetupRootCommand setups cobra command and returns CLI client options, flags and help command.

func ShowHelp

func ShowHelp(out io.Writer) func(*cobra.Command, []string) error

ShowHelp shows the command help.

func VisitAll

func VisitAll(root *cobra.Command, fn func(*cobra.Command))

VisitAll will traverse all commands from the root. This is different from the VisitAll of cobra.Command where only parents are checked.

Types

type DumpOptions

type DumpOptions struct {
	Models []string
	View   string
}

type Errors

type Errors []error

Errors is a list of errors. Useful in a loop if you don't want to return the error right away and you want to display after the loop, all the errors that happened during the loop.

func (Errors) Error

func (errList Errors) Error() string

type GenerateOptions

type GenerateOptions struct {
	Model   string
	Format  string
	OneLine bool
}

type ImportOptions

type ImportOptions struct {
	InputFile string
	TxOps     uint
	Timeout   time.Duration
	ViaGrpc   bool
}

type LogListOptions

type LogListOptions struct {
	Name string
}

type LogSetOptions

type LogSetOptions struct {
	Logger string
	Level  string
}

type ModelInspectOptions

type ModelInspectOptions struct {
	Names  []string
	Format string
}

type ModelListOptions

type ModelListOptions struct {
	Refs []string
}

type Root

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

Root encapsulates a top-level cobra command (either agentctl or custom one).

func NewRoot

func NewRoot(agentCli *cli.AgentCli) *Root

NewRoot returns new Root using RootName for name.

func NewRootNamed

func NewRootNamed(name string, agentCli *cli.AgentCli) *Root

NewRootNamed returns new Root named with name.

func (*Root) HandleGlobalFlags

func (root *Root) HandleGlobalFlags() (*cobra.Command, []string, error)

HandleGlobalFlags takes care of parsing global flags defined on the command, it returns the underlying cobra command and the args it will be called with (or an error).

On success the caller is responsible for calling Initialize() before calling `Execute` on the returned command.

func (*Root) Initialize

func (root *Root) Initialize(ops ...cli.InitializeOpt) error

Initialize finalises global option parsing and initializes the agentctl client.

func (*Root) PrepareCommand

func (root *Root) PrepareCommand() (*cobra.Command, error)

PrepareCommand handles global flags and Initialize should be called before executing returned cobra command.

type StatusError

type StatusError struct {
	Status     string
	StatusCode int
}

StatusError reports an unsuccessful exit by a command.

func (StatusError) Error

func (e StatusError) Error() string

func (StatusError) String

func (e StatusError) String() string

type StatusOptions

type StatusOptions struct {
	Format string
}

type ValuesOptions

type ValuesOptions struct {
	Models []string
}

Jump to

Keyboard shortcuts

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