command

package
v1.20.5 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatText   = "text"
	FormatInline = "inline"
	FormatJSON   = "json"
)

Variables

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

Flags initialized to default values.

View Source
var UsageTemplate = `` /* 1594-byte string literal not displayed */

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.

func UsageMetrics added in v0.45.2

func UsageMetrics(command *cobra.Command, wg *sync.WaitGroup)

Types

type Command

type Command struct {
	Cmd   *cobra.Command
	Flags any
	Run   run
	RunS  RunWithState
}

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
	HostNetworkKey   string
	Log              string
	Network          string
	Yes              bool
	ConfigPaths      []string
	SkipVersionCheck bool
}

GlobalFlags contains all global flags definitions.

type Result

type Result interface {
	// String will output the result in human readable output.
	String() string
	// Oneliner will output the result in "grep-able" format.
	Oneliner() string
	// JSON will output the result in JSON format
	JSON() any
}

Result interface describes all the formats for the result output.

type ResultWithExitCode added in v1.15.0

type ResultWithExitCode interface {
	Result
	ExitCode() int
}

type RunWithState added in v0.24.0

type RunWithState func(
	args []string,
	globalFlags GlobalFlags,
	logger output.Logger,
	flow flowkit.Services,
	state *flowkit.State,
) (Result, error)

RunWithState runs the command with arguments and state.

Jump to

Keyboard shortcuts

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