cmd

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InsprOptions struct {
	SampleFlagValue string
	// Scope receives the dApp scope/context from the cli
	Scope string
	// AppliedFileStructure receives the folder/file to be applied
	AppliedFileStructure string
	// AppliedFolderStructure receives the folder/file to be applied
	AppliedFolderStructure string
	// DryRun defines if given command will be a dry run or not
	DryRun bool
	// Update defines if Apply is going to create a new app or update an existing one
	Update bool

	Token string

	Config string
	// Host receives the request Host/Header field from the cli
	Host string
}

InsprOptions values for the cli

Functions

func AddFlags

func AddFlags(cmd *cobra.Command)

AddFlags adds to the command the common flags that are annotated with the command name.

func ParseFlags

func ParseFlags(cmd *cobra.Command, flags []*Flag)

ParseFlags - adds flags to the cmd given

Types

type Builder

type Builder interface {
	WithAliases(...string) Builder
	WithDescription(description string) Builder
	WithLongDescription(long string) Builder
	WithExample(comment, command string) Builder
	WithFlagAdder(adder func(*pflag.FlagSet)) Builder
	WithFlags(...*Flag) Builder
	WithCommonFlags() Builder
	Hidden() Builder
	ExactArgs(argCount int, action func(context.Context, []string) error) *cobra.Command
	MinimumArgs(argCount int, action func(context.Context, []string) error) *cobra.Command
	NoArgs(action func(context.Context) error) *cobra.Command
	AddSubCommand(cmds ...*cobra.Command) Builder
	Version(version string) Builder
	WithOptions(...Option) Builder
	ValidArgsFunc(validation func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)) Builder
	WithRequiredFlag(string) Builder
	Super() *cobra.Command
}

Builder is used to build cobra commands. it contains all the methods to manipulate a command

func NewCmd

func NewCmd(use string) Builder

NewCmd creates a new command builder.

type Flag

type Flag struct {
	Name      string
	Shorthand string
	Usage     string
	// Pointer to where the value of the flag will be stored
	Value interface{}

	// Default value of the flag. Needs to be set and determines the type of the flag that will be created
	DefValue           interface{}
	DefValuePerCommand map[string]interface{}
	FlagAddMethod      string
	DefinedOn          []string
	Hidden             bool
	// contains filtered or unexported fields
}

Flag defines a INSPR CLI flag which contains a list of subcommands the flag belongs to in `DefinedOn` field.

func (*Flag) Flag

func (fl *Flag) Flag() *pflag.Flag

Flag return a pflag.Flag from the insprCMD-flag

type Option added in v0.1.3

type Option func(*cobra.Command)

Option is an option to be applied on the construction of a command

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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