Documentation
¶
Index ¶
- Constants
- Variables
- func ValidateName(name string) (err error)
- type App
- func (a *App) ActiveCommand() *Command
- func (c *App) CommandUsage(cmd string) string
- func (a *App) DefaultValues() values
- func (a *App) EnvVar(o optionInterface) string
- func (a *App) GetCommandByName(name string) *Command
- func (a *App) NewCommand(fn func(a *App) error, name string) *Command
- func (a *App) Reset()
- func (a *App) Run() (err error)
- func (a *App) SaveToGlobalConfig(opts ...optionInterface) error
- func (a *App) SaveToLocalConfig(opts ...optionInterface) error
- func (a *App) SaveToUserConfig(opts ...optionInterface) error
- func (a *App) SetArgs(args []string) *App
- func (a *App) SetHelp(str string) *App
- func (a *App) SetVersion(maj, min, patch int) *App
- func (c *App) Usage() string
- func (a *App) WithAsciiArt() *App
- type Bool
- type Command
- func (c *Command) Bool(target *bool, name string) *Option[bool]
- func (c *Command) Date(target *Time, name string) *Option[Time]
- func (c *Command) DateTime(target *Time, name, format string) *Option[Time]
- func (c *Command) Float(target *float64, name string) *Option[float64]
- func (c *Command) Floats(target *[]float64, name string) *Option[[]float64]
- func (c *Command) GetLastOption() optionInterface
- func (c *Command) GetOptionByName(name string) optionInterface
- func (c *Command) HasLastOption() bool
- func (c Command) Help() string
- func (c *Command) Int(target *int, name string) *Option[int]
- func (c *Command) Ints(target *[]int, name string) *Option[[]int]
- func (c *Command) Json(target *Json, name string) *Option[Json]
- func (c *Command) MultiSelect(target *[]string, name string, choices []string) *Option[[]string]
- func (c *Command) MultiSelectInput(target *[]string, name string, choices []string) *Option[[]string]
- func (c Command) Name() string
- func (c *Command) Path(target *Path, name string) *Option[Path]
- func (c *Command) Relax(opts ...string) *Command
- func (c *Command) Select(target *string, name string, choices []string) *Option[string]
- func (c *Command) SelectInput(target *string, name string, choices []string) *Option[string]
- func (c *Command) SetHelp(str string) *Command
- func (c *Command) Skip(opts ...string) *Command
- func (c *Command) SkipAllBut(except ...string) *Command
- func (c *Command) String(target *string, name string) *Option[string]
- func (c *Command) Strings(target *[]string, name string) *Option[[]string]
- func (c *Command) Time(target *Time, name string) *Option[Time]
- func (c *Command) TimeShort(target *Time, name string) *Option[Time]
- type Datetime
- type Float
- type Floats
- type Int
- type Ints
- type InvalidNameError
- type Json
- type MultiSelect
- type Option
- func (o *Option[T]) Command() string
- func (o *Option[T]) Default() any
- func (o *Option[T]) Get() (v T)
- func (o *Option[T]) Help() string
- func (o *Option[T]) IsSet() bool
- func (o *Option[T]) Name() string
- func (o *Option[T]) Required() bool
- func (o *Option[T]) Set(s string) error
- func (o *Option[T]) SetAsLast() *Option[T]
- func (o *Option[T]) SetDefault(v T) *Option[T]
- func (o *Option[T]) SetHelp(str string) *Option[T]
- func (o *Option[T]) SetRequired() *Option[T]
- func (o *Option[T]) SetShortflag(r rune) *Option[T]
- func (o *Option[T]) SetValidator(v Validator[T]) *Option[T]
- func (o *Option[T]) ShortFlag() string
- func (o *Option[T]) Type() string
- func (o *Option[T]) Validate() error
- func (o *Option[T]) Value() any
- type Path
- type Select
- type String
- type Strings
- type Time
- type TypeHandler
- type Validator
Constants ¶
View Source
const ( MaxLenOptionName = 18 MaxLenCommandName = 20 MaxLenAppName = 30 DateFormat = Datetime("YYYY-MM-DD") TimeFormat = Datetime("hh:mm:ss") TimeFormatShort = Datetime("hh:mm") )
View Source
const ( LocalConfig fileType = "local" UserConfig fileType = "user" GlobalConfig fileType = "global" )
Variables ¶
View Source
var ( //USER_DIR string CONFIG_DIR string GLOBAL_DIRS string // colon separated list to look for WORKING_DIR string CONFIG_EXT = ".conf" )
Functions ¶
func ValidateName ¶
rules for names:
must not start with numbers may not have more than an underscore in a row may not have more than a dash in a row may not start or end with an underscore may not start or end with a dash may not have an underscore followed by a dash may not have a dash followed by an underscore other than that, just lowercase letters are allowed we need at least two characters
Types ¶
type App ¶
type App struct { Name string Description string Version version.Version *Command Commands []*Command // contains filtered or unexported fields }
func (*App) ActiveCommand ¶
func (*App) CommandUsage ¶
func (*App) DefaultValues ¶
func (a *App) DefaultValues() values
func (*App) GetCommandByName ¶
func (*App) SaveToGlobalConfig ¶
func (*App) SaveToLocalConfig ¶
func (*App) SaveToUserConfig ¶
func (*App) SetVersion ¶
func (*App) WithAsciiArt ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
func (*Command) DateTime ¶
DateTime allows a date/time input in the format defined by the given format string (MS Excel style)
func (*Command) GetLastOption ¶
func (c *Command) GetLastOption() optionInterface
func (*Command) GetOptionByName ¶
func (*Command) HasLastOption ¶
func (*Command) MultiSelect ¶
MultiSelect offers a range of choices to select multiple from (separated by #)
func (*Command) MultiSelectInput ¶
func (c *Command) MultiSelectInput(target *[]string, name string, choices []string) *Option[[]string]
MultiSelectInput offers a range of choices to select multiple from (separated by #), but also user defined strings can be used
func (*Command) SelectInput ¶
SelectInput offers a range of choices to select from, but also a user defined string can be used
func (*Command) SkipAllBut ¶
type InvalidNameError ¶
type InvalidNameError string
func (InvalidNameError) Error ¶
func (e InvalidNameError) Error() string
type MultiSelect ¶
func (MultiSelect) ToString ¶
func (MultiSelect) ToString(s []string) string
func (MultiSelect) Type ¶
func (s MultiSelect) Type() string
type Option ¶
type Option[T any] struct { // contains filtered or unexported fields }
func Custom ¶
func Custom[T any](c *Command, target *T, name string, type_ TypeHandler[T]) *Option[T]
Custom creates a custom option for any given type
func (*Option[T]) SetDefault ¶
func (*Option[T]) SetRequired ¶
func (*Option[T]) SetShortflag ¶
func (*Option[T]) SetValidator ¶
maybe that can just become a method of Type ? (and wrapped for further validations?)
type TypeHandler ¶
Click to show internal directories.
Click to hide internal directories.