Documentation ¶
Overview ¶
Package mains contains functions for executing a command-line utility
Index ¶
- Constants
- func Abs(dir string) (out string)
- func ExecDir() (dir string)
- func FindFile(filename0, program string) (out string, bytes []byte)
- func GetStringSliceValue(p *[]string, value []string) (v flag.Value)
- func GetTopLevelKey(topKey string) (key string)
- func Keystrokes(ctx ev.Callee)
- func ParentDir() (dir string)
- func Timer(ctx ev.Callee)
- func UserHomeDir() (dir string)
- type ArgumentSpec
- type BaseOptionsType
- type Executable
- func (ex *Executable) AddErr(err error) (x *Executable)
- func (ex *Executable) ApplyYaml(yamlFile, yamlKey string, thunk UnmarshalThunk, om []OptionData)
- func (ex *Executable) ConfigureLog() (ex1 *Executable)
- func (ex *Executable) Exit()
- func (ex *Executable) Init() *Executable
- func (ex *Executable) LongErrors(isLongErrors bool, isErrorLocation bool) *Executable
- func (ex *Executable) PrintBannerAndParseOptions(om []OptionData) (ex1 *Executable)
- func (ex *Executable) PrintErr(err error)
- func (ex *Executable) Recover()
- type InputLine
- type OptionData
- type Status
- type StringSliceValue
- type UnmarshalFunc
- type UnmarshalThunk
- type YamlOption
- type YamlValue
Constants ¶
const ( // NoArguments besides switches, zero trailing arguments is allowed NoArguments = 1 << iota // OneArgument besides switches, exactly one trailing arguments is allowed OneArgument // ManyArguments besides switches, one or more trailing arguments is allowed ManyArguments )
const (
SilentString = "-" + silentOption
)
Variables ¶
This section is empty.
Functions ¶
func GetStringSliceValue ¶
GetStringSliceValue initializes
func GetTopLevelKey ¶
GetTopLevelKey gets the top level key to use
func ParentDir ¶
func ParentDir() (dir string)
ParentDir gets absolute path of executable parent directory
func UserHomeDir ¶
func UserHomeDir() (dir string)
UserHomeDir gets file system path of user’s home directory
Types ¶
type ArgumentSpec ¶
type ArgumentSpec uint32
ArgumentSpec bitfield for 0, 1, many arguments following command-line switches
type BaseOptionsType ¶
type BaseOptionsType = struct { YamlFile string YamlKey string Verbosity string Debug bool Silent bool }
var BaseOptions BaseOptionsType
type Executable ¶
type Executable struct { Program string // gonet Version string // 0.0.1 Comment string // [ banner text after program and version] options parsing (about this version) Description string // [Description part of usage] configures firewall and routing Copyright string // © 2020… License string // ISC License ArgumentsUsage string Arguments ArgumentSpec // eg. NoArguments // fields below popualted by .Init() Launch time.Time LaunchString string Host string // short hostname, ie. no dots ArgCount int Arg string Args []string IsLongErrors bool IsErrorLocation bool // contains filtered or unexported fields }
Executable constant strings that describes an executable
func (*Executable) AddErr ¶
func (ex *Executable) AddErr(err error) (x *Executable)
AddErr extended with immediate printing of first error
func (*Executable) ApplyYaml ¶
func (ex *Executable) ApplyYaml(yamlFile, yamlKey string, thunk UnmarshalThunk, om []OptionData)
func (*Executable) ConfigureLog ¶
func (ex *Executable) ConfigureLog() (ex1 *Executable)
func (*Executable) Exit ¶
func (ex *Executable) Exit()
Exit terminate from mains.err: exit 0 or echo to stderr and status code 1
func (*Executable) Init ¶
func (ex *Executable) Init() *Executable
Init populate launch time — may throw
func (*Executable) LongErrors ¶
func (ex *Executable) LongErrors(isLongErrors bool, isErrorLocation bool) *Executable
LongErrors sets if errors are printed with stack trace and values
func (*Executable) PrintBannerAndParseOptions ¶
func (ex *Executable) PrintBannerAndParseOptions(om []OptionData) (ex1 *Executable)
PrintBannerAndParseOptions prints greeting
func (*Executable) Recover ¶
func (ex *Executable) Recover()
Recover function to be deferred in main()
type OptionData ¶
type OptionData struct { P interface{} Name string Value interface{} Usage string Y *YamlValue // pointer to data value from yaml }
OptionData contain options data for the flag package
func BaseOptionData ¶
func BaseOptionData(program string, yaml YamlOption) (od []OptionData)
func (*OptionData) AddOption ¶
func (om *OptionData) AddOption()
AddOption executes flag.BoolVar and such on the options map
func (*OptionData) ApplyYaml ¶
func (om *OptionData) ApplyYaml() (err error)
type Status ¶
type Status struct {
// contains filtered or unexported fields
}
Status handles printing of status to stdout
type StringSliceValue ¶
type StringSliceValue struct {
// contains filtered or unexported fields
}
StringSliceValue manages a string-slice value for flag.Var
func (*StringSliceValue) Set ¶
func (v *StringSliceValue) Set(s string) (err error)
Set updates the string slice
func (StringSliceValue) String ¶
func (v StringSliceValue) String() (s string)
type UnmarshalFunc ¶
type UnmarshalThunk ¶
type UnmarshalThunk func(bytes []byte, unmarshal UnmarshalFunc, yamlKey string) (hasDate bool, err error)
type YamlOption ¶
type YamlOption bool
const ( YamlNo YamlOption = false YamlYes YamlOption = true )