command

package
v0.36.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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

Flags initialized to default values.

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   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
}

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() interface{}
}

Result interface describes all the formats for the result output.

type Run added in v0.24.0

type Run func(
	args []string,
	readerWriter flowkit.ReaderWriter,
	globalFlags GlobalFlags,
	services *services.Services,
) (Result, error)

Run the command with arguments.

type RunWithState added in v0.24.0

type RunWithState func(
	args []string,
	readerWriter flowkit.ReaderWriter,
	globalFlags GlobalFlags,
	services *services.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