args

package module
v0.0.0-...-911008f Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: MIT Imports: 4 Imported by: 0

README

Port of the argument parser from this.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ANSICode

type ANSICode string
const (
	ANSIDefault   ANSICode = "\033[39m"
	ANSIBGDefault ANSICode = "\033[49m"
	ANSIBlack     ANSICode = "\033[30m"
	ANSIRed       ANSICode = "\033[31m"
	ANSIGreen     ANSICode = "\033[32m"
	ANSIYellow    ANSICode = "\033[33m"
	ANSIBlue      ANSICode = "\033[34m"
	ANSIMagenta   ANSICode = "\033[35m"
	ANSICyan      ANSICode = "\033[36m"
	ANSIWhite     ANSICode = "\033[37m"
	ANSIBGBlack   ANSICode = "\033[40m"
	ANSIBGRed     ANSICode = "\033[41m"
	ANSIBGGreen   ANSICode = "\033[42m"
	ANSIBGYellow  ANSICode = "\033[43m"
	ANSIBGBlue    ANSICode = "\033[44m"
	ANSIBGMagenta ANSICode = "\033[45m"
	ANSIBGCyan    ANSICode = "\033[46m"
	ANSIBGWhite   ANSICode = "\033[47m"
)

type ArgParser

type ArgParser struct {
	CommandRequired         bool
	CommandsHelpMsg         string
	FlagsHelpMsg            string
	OptionsHelpMsg          string
	Colors                  bool
	TitleColor              ANSICode
	DescriptionColor        ANSICode
	HeaderColor             ANSICode
	CommandColor            ANSICode
	CommandDescriptionColor ANSICode
	FlagColor               ANSICode
	FlagDescriptionColor    ANSICode
	OptionColor             ANSICode
	OptionDescriptionColor  ANSICode
	OptionAllowedColor      ANSICode
	// contains filtered or unexported fields
}

func (*ArgParser) AddCommand

func (ap *ArgParser) AddCommand(name string, help string) error

func (*ArgParser) AddFlag

func (ap *ArgParser) AddFlag(name string, help string, abbr rune) error

func (*ArgParser) AddOption

func (ap *ArgParser) AddOption(
	name string, help string, abbr rune, defaultsTo string, allowed []string,
) error

func (*ArgParser) Help

func (ap *ArgParser) Help()

func (*ArgParser) Init

func (ap *ArgParser) Init(name string, description string)

func (*ArgParser) Parse

func (ap *ArgParser) Parse() (*ArgResults, error)

type ArgResults

type ArgResults struct {
	Flag       map[string]bool
	Option     map[string]string
	Positional []string
	Command    string
}

Jump to

Keyboard shortcuts

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