cli

package
v0.26.1-rc3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HomeFlag     = "home"
	TraceFlag    = "trace"
	OutputFlag   = "output"
	EncodingFlag = "encoding"
)

Variables

This section is empty.

Functions

func RunCaptureWithArgs

func RunCaptureWithArgs(cmd Executable, args []string, env map[string]string) (stdout, stderr string, err error)

RunCaptureWithArgs executes the given command with the specified command line args and environmental variables set. It returns string fields representing output written to stdout and stderr, additionally any error from cmd.Execute() is also returned

func RunWithArgs

func RunWithArgs(cmd Executable, args []string, env map[string]string) error

RunWithArgs executes the given command with the specified command line args and environmental variables set. It returns any error returned from cmd.Execute()

func WriteConfigVals

func WriteConfigVals(dir string, vals map[string]string) error

WriteConfigVals writes a toml file with the given values. It returns an error if writing was impossible.

Types

type Executable

type Executable interface {
	Execute() error
}

Executable is the minimal interface to *corba.Command, so we can wrap if desired before the test

type Executor

type Executor struct {
	*cobra.Command
	Exit func(int) // this is os.Exit by default, override in tests
}

Executor wraps the cobra Command with a nicer Execute method

func PrepareBaseCmd

func PrepareBaseCmd(cmd *cobra.Command, envPrefix, defaultHome string) Executor

PrepareBaseCmd is meant for tendermint and other servers

func PrepareMainCmd

func PrepareMainCmd(cmd *cobra.Command, envPrefix, defaultHome string) Executor

PrepareMainCmd is meant for client side libs that want some more flags

This adds --encoding (hex, btc, base64) and --output (text, json) to the command. These only really make sense in interactive commands.

func (Executor) Execute

func (e Executor) Execute() error

execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

type ExitCoder

type ExitCoder interface {
	ExitCode() int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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