command

package
v0.0.1-cd Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Flags = GlobalFlags{
	Filter:      "",
	Format:      formatText,
	Save:        "",
	Host:        "",
	Network:     config.DefaultEmulatorNetwork().Name,
	Log:         logLevelInfo,
	Yes:         false,
	ConfigPaths: config.DefaultPaths(),
}

Functions

func ContainsFlag added in v0.21.0

func ContainsFlag(flags []string, field string) bool

ContainsFlag checks if output flag is present for the provided field

func InitFlags

func InitFlags(cmd *cobra.Command)

InitFlags init all the global persistent flags

Types

type Command

type Command struct {
	Cmd   *cobra.Command
	Flags interface{}
	Run   RunCommand
}

func (Command) AddToParent

func (c Command) AddToParent(parent *cobra.Command)

AddToParent add new command to main parent cmd and initializes all necessary things as well as take care of errors and output here we can do all boilerplate code that is else copied in each command and make sure we have one place to handle all errors and ensure commands have consistent results

type GlobalFlags

type GlobalFlags struct {
	Filter      string
	Format      string
	Save        string
	Host        string
	Log         string
	Network     string
	Yes         bool
	ConfigPaths []string
}

type Result

type Result interface {
	String() string
	Oneliner() string
	JSON() interface{}
}

type RunCommand

type RunCommand func(
	*cobra.Command,
	[]string,
	GlobalFlags,
	*services.Services,
) (Result, error)

Jump to

Keyboard shortcuts

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