cli

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdFlag

type CmdFlag struct {
	Name         string
	Type         FlagType
	DefaultValue interface{}
	Usage        string
	ConfigKey    string
}

CmdFlag describes a flag setting

func (CmdFlag) ApplyToCommand

func (f CmdFlag) ApplyToCommand(cmd *cobra.Command)

ApplyToCommand adds the flag to a command

func (CmdFlag) KeyString

func (f CmdFlag) KeyString() string

KeyString returns the Config Key provided or translated from the flag name replacing '-' with '.'

func (CmdFlag) UsageString

func (f CmdFlag) UsageString() string

UsageString returns the usage string including the environment variable name

type CmdSettings

type CmdSettings struct {
	UseHint          string
	ShortDescription string
	LongDescription  string
	Setup            func(args []string)
	Run              func(args []string)
	Flags            []CmdFlag
}

CmdSettings provides the command settings for the CLI

func (CmdSettings) GetCommand

func (s CmdSettings) GetCommand() *cobra.Command

GetCommand returns a command with the settings

type FlagType

type FlagType int

FlagType describes the data type of a flag

const (
	// StringFlag for a flag with string value
	StringFlag FlagType = iota
	// IntFlag for a flag with a int value
	IntFlag
	// BoolFlag for a flag with a boolean value
	BoolFlag
	// DurationFlag for a flag with a duration value
	DurationFlag
)

type SimpleApp

type SimpleApp struct {
	// contains filtered or unexported fields
}

SimpleApp ṕrovides a single command CLI

func NewSimpleApp

func NewSimpleApp(settings CmdSettings) *SimpleApp

NewSimpleApp returns a new instance of a simple application

func (SimpleApp) Run

func (a SimpleApp) Run()

Run prepares and executes the application

Jump to

Keyboard shortcuts

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