Documentation ¶
Index ¶
- Constants
- func AppDataName() string
- func CollectItems(helpstring string) (map[string]CmdLineItem, string, string)
- func CollectItemsFromJSON(jsonStr string) (map[string]CmdLineItem, error)
- func PrintCli(cli *CLI)
- func PrintItem(it CmdLineItem)
- func PrintMap(items map[string]CmdLineItem)
- func StringFromCode(code ParseErrCode) string
- func TypeToString(p ParameterType) string
- type CLI
- func (C *CLI) Bool(item string) (bool, bool)
- func (C *CLI) Date(item string) (time.Time, bool)
- func (C *CLI) DateSlice(item string) ([]time.Time, bool)
- func (C *CLI) Email(item string) (mail.Address, bool)
- func (C *CLI) EmailSlice(item string) ([]mail.Address, bool)
- func (C *CLI) Errors() string
- func (C *CLI) Float(item string) (float64, bool)
- func (C *CLI) FloatSlice(item string) ([]float64, bool)
- func (C *CLI) HasErrors() bool
- func (C *CLI) Help(topic string, ty ...HelpType) string
- func (C *CLI) IPv4(item string) (net.IP, bool)
- func (C *CLI) IPv4Slice(item string) ([]net.IP, bool)
- func (C *CLI) Int(item string) (int, bool)
- func (C *CLI) IntSlice(item string) ([]int, bool)
- func (C *CLI) LastError() error
- func (C *CLI) Path(item string) (string, bool)
- func (C *CLI) PathSlice(item string) ([]string, bool)
- func (C *CLI) SetError(err error)
- func (C *CLI) String(item string) (string, bool)
- func (C *CLI) StringSlice(item string) ([]string, bool)
- func (C *CLI) Time(item string) (time.Time, bool)
- func (C *CLI) TimeDuration(item string) (time.Duration, bool)
- func (C *CLI) TimeDurationSlice(item string) ([]time.Duration, bool)
- func (C *CLI) TimeSSlice(item string) ([]time.Time, bool)
- func (C *CLI) URL(item string) (url.URL, bool)
- func (C *CLI) URLSlice(item string) ([]url.URL, bool)
- type CmdLineItem
- type HelpType
- type ParameterType
- type ParseErrCode
- type ParseError
Constants ¶
View Source
const ( Usagepat = `^[Uu]{1}sage: ` CommandSectionPat = `^Commands[\t ]*:` FlagSectionPat = `^Flags[\t ]*:` MoreSectionPat = `^More[\t ]*:` LongSectionPat = `^Long Description[\t ]*:` )
Variables ¶
This section is empty.
Functions ¶
func AppDataName ¶
func AppDataName() string
func CollectItems ¶
func CollectItems(helpstring string) (map[string]CmdLineItem, string, string)
func CollectItemsFromJSON ¶
func CollectItemsFromJSON(jsonStr string) (map[string]CmdLineItem, error)
func PrintItem ¶
func PrintItem(it CmdLineItem)
func PrintMap ¶
func PrintMap(items map[string]CmdLineItem)
func StringFromCode ¶
func StringFromCode(code ParseErrCode) string
func TypeToString ¶
func TypeToString(p ParameterType) string
Types ¶
type CLI ¶
type CLI struct { Application string Items map[string]CmdLineItem AllHelp map[string]string Errs []error }
func ParseCommandLineArgs ¶
func ParseCommandLineArgs(cmds map[string]CmdLineItem, args []string) *CLI
func (*CLI) TimeDurationSlice ¶
type CmdLineItem ¶
type CmdLineItem struct { ParamType ParameterType Value any Name string Alias string ShortHelp string LongHelp string IsDefault bool IsFlag bool Exclusive bool Required bool RequiredOr []string RequiredAnd []string ParamOpt bool ParamCount int Extra string // the boa-gui tool uses this field for code generation Disabled bool // the boa-gui tool uses this field for script editing Id int // use as index to sort the items in as read order }
type ParameterType ¶
type ParameterType int
const ( TypeBool ParameterType = iota TypeString TypeStringSlice TypeInt TypeIntSlice TypeFloat TypeFloatSlice TypeTime TypeTimeSlice TypeTimeDuration TypeTimeDurationSlice TypeDate TypeDateSlice TypePath TypePathSlice TypeURL TypeURLSlice TypeIPv4 TypeIPv4Slice TypeEmail TypeEmailSlice TypePhone TypePhoneSlice )
type ParseErrCode ¶
type ParseErrCode int
const ( //errors from reading input script BeExternalError ParseErrCode = iota //"expecting a file path for input script" BeNoFileGiven //"input script is not formatted as a Boa input script" BeWrongFileFormat //"cannot read input script %s" BeFileReadError //"section %s has no content at line %d" BeNoSectionText // "unsupported argument type at line %d" BeUnsupportedType //"reached end of input script" BeEofError //"line only contains meta characters" BeBadMetaLine //"meta character string is not at beginning of line" BeMetaNotStart //"command or flag in input script cannot be parsed" BeNoCommandName //"item %s is exclusive but was found with %s" BeNoExclusiveItem //"item %s is required but was not found" BeNoRequiredItem //"command or flag passed on command line is not recognized" BeInvalidCommand //"argument for %s not found" BeNoRequiredString //"integer argument for %s not found" BeNoRequiredInt //"real number argument for %s not found" BeNoRequiredFloat //"date argument for %s not found" BeNoRequiredDate // "time argument for %s not found" BeNoRequiredTime //"time duration argument for %s not found" BeNoRequiredDuration //"file path argument for %s not found" BeNoRequiredPath //"URL argument for %s not found" BeNoRequiredURL //"Email address argument for %s npt found" BeNoRequiredEmail //"Phone number argument for %s not found" BeNoRequiredPhone //"IP address argument for %s not found" BeNoRequiredIPv4 //"%s, argument for %s, cannot be interpreted as a boolean" BeNotABool //"%s, argument for %s, cannot be interpreted as an integer" BeNotAnInt // "%s, argument for %s, cannot be interpreted as a real number" BeNotAFloat // "argument to %s, %s is not a valid date value such as '01-01-2022'" BeNotADate //"argument to %s, %s is not a valid time value such as '3:45PM'" BeNotATime //"argument to %s, %s is not a valid duration value such as '1h10m20s'" BeNotADuration //"%s, argument for %s, cannot be interpreted as an email address" BeNotAnEmail //"%s, argument for %s, cannot be interpreted as a phone number" BeNotAPhone //"%s, argument for %s, cannot be interpreted as a file path" BeNotAPath //"%s, argument for %s, cannot be interpreted as a URL" BeNotAURL //"%s, argument for %s, cannot be interpreted as an IP address of IPv4 format" BeNotAnIPv4 )
func (ParseErrCode) String ¶
func (e ParseErrCode) String() string
type ParseError ¶
type ParseError struct { Code ParseErrCode Err error }
func ErrorFromCode ¶
func ErrorFromCode(code ParseErrCode, args ...any) ParseError
func NewParseError ¶
func NewParseError(code ParseErrCode, fmtstr string, args ...any) ParseError
func (ParseError) Error ¶
func (e ParseError) Error() string
Click to show internal directories.
Click to hide internal directories.