command

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoNothing

func DoNothing(_ flag.PassedFlags) error

DoNothing is a command action that simply returns nil Useful for prototyping

Types

type Action

type Action = func(flag.PassedFlags) error

An Action is run as the result of a command

type Command

type Command struct {
	Action Action
	Flags  flag.FlagMap
	// HelpShort is a required one-line description
	HelpShort HelpShort
	// Footer is yet another optional longer description.
	Footer string
	// HelpLong is an optional longer description
	HelpLong string
}

A Command will run code for you! The name of a Command should probably be a verb - add , edit, run, ... It should not be constructed directly - use AddCommand/NewCommand/WithCommand functions

func New added in v0.0.2

func New(helpShort HelpShort, action Action, opts ...CommandOpt) Command

New builds a Command

type CommandMap

type CommandMap = map[Name]Command

A CommandMap holds Commands and is used by Sections

type CommandOpt

type CommandOpt = func(*Command)

A CommandOpt customizes a Command

func ExistingFlag added in v0.0.5

func ExistingFlag(name flag.Name, value flag.Flag) CommandOpt

ExistingFlag adds an existing flag to a Command. It panics if a flag with the same name exists

func ExistingFlags added in v0.0.5

func ExistingFlags(flagMap flag.FlagMap) CommandOpt

func Flag added in v0.0.5

func Flag(name flag.Name, helpShort flag.HelpShort, empty value.EmptyConstructor, opts ...flag.FlagOpt) CommandOpt

Flag builds a flag and adds it to a Command. It panics if a flag with the same name exists

func Footer(footer string) CommandOpt

Footer adds an Help string to the command - useful from a help function

func HelpLong

func HelpLong(helpLong string) CommandOpt

HelpLong adds an Help string to the command - useful from a help function

type HelpShort added in v0.0.8

type HelpShort string

type Name added in v0.0.8

type Name string

Name of the command

Jump to

Keyboard shortcuts

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