Documentation
¶
Overview ¶
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2026 Dídimo Grimaldo T. * APP_NAME * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * A custom Byte flag for the flag package that can be displayed as rune. *-----------------------------------------------------------------
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2026 Dídimo Grimaldo T. * APP_NAME * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * A custom Date Flag for the GO flag package. You can specify dates * in various formats as defined by your application. *-----------------------------------------------------------------
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2026 Dídimo Grimaldo T. * go-App * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Utility object to handle command-line sub-commands using the * standard flag package. Moved here from goVault. *-----------------------------------------------------------------
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2026 Dídimo Grimaldo T. * APP_NAME * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * A custom Rune Flag for the GO flag package. We can now use rune * flags in the command line. For that we implement the flag.Value * interface. * This implementation works with both single and multi-byte runes. *-----------------------------------------------------------------
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * A Flag for the GO flag package. Useful when you want a flag/CLI option * to be any of a pre-determined list of strings. *-----------------------------------------------------------------
Index ¶
- func RegisterByteVar(r *ByteFlag, name string, usage string)
- func RegisterByteVarSet(r *ByteFlag, name string, value byte, usage string)
- func RegisterDateVar(r *DateFlag, name string, usage string, formats ...string)
- func RegisterRuneVar(r *RuneFlag, name string, value rune, usage string)
- func ThisMonth() time.Time
- func ThisYear() time.Time
- func Today() time.Time
- type ByteFlag
- type DateFlag
- type FlagSubCommander
- func (fsc *FlagSubCommander) ChosenCommand() *flag.FlagSet
- func (fsc *FlagSubCommander) ChosenCommandName() string
- func (fsc *FlagSubCommander) Define(subCommandName string, eh flag.ErrorHandling) *flag.FlagSet
- func (fsc *FlagSubCommander) FreeArguments() []string
- func (fsc *FlagSubCommander) IsValidSubcommand(name string) bool
- func (fsc *FlagSubCommander) Parse() error
- func (fsc *FlagSubCommander) String() string
- type RuneFlag
- type StringsFlag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterByteVar ¶
func RegisterByteVarSet ¶
func RegisterDateVar ¶
registers an instance of DateFlag with the flag package for parsing.
Types ¶
type DateFlag ¶
func NewDateVar ¶
func (*DateFlag) Set ¶
invoked by flag.Parse() to set the value. We attempt to convert the date with "now" or "ahora" to a full date/time, "today" and "hoy" to today's date without time, or to the first interpretation of the formats given at the constructor. Else an error is produced. Time is in UTC.
type FlagSubCommander ¶ added in v1.4.1
type FlagSubCommander struct {
// contains filtered or unexported fields
}
func NewFlagSubCommander ¶ added in v1.4.1
func NewFlagSubCommander() *FlagSubCommander
(ctor) utility for dealing with flag subcommands
func (*FlagSubCommander) ChosenCommand ¶ added in v1.4.1
func (fsc *FlagSubCommander) ChosenCommand() *flag.FlagSet
After Parse() without error this method returns the flagset corresponding to the selected sub-command.
func (*FlagSubCommander) ChosenCommandName ¶ added in v1.4.1
func (fsc *FlagSubCommander) ChosenCommandName() string
After Parse() without error this method returns the name of the sub-command.
func (*FlagSubCommander) Define ¶ added in v1.4.1
func (fsc *FlagSubCommander) Define(subCommandName string, eh flag.ErrorHandling) *flag.FlagSet
Defines a new flag set (subcommand) with the subcommand name and error handling directive (ExitOnError, ContinueOnError, PanicOnError). if already defined a warning message is produced but returns the previously-defined flag set.
func (*FlagSubCommander) FreeArguments ¶ added in v1.4.1
func (fsc *FlagSubCommander) FreeArguments() []string
Returns the free arguments after the flags of the sub-command.
func (*FlagSubCommander) IsValidSubcommand ¶ added in v1.4.1
func (fsc *FlagSubCommander) IsValidSubcommand(name string) bool
Returns true if name represents a valid/registered sub-command. It is normalized to lowercase.
func (*FlagSubCommander) Parse ¶ added in v1.4.1
func (fsc *FlagSubCommander) Parse() error
Verifies that the subcommand name is given and parses the flags after the subcommand, returning nil or an error if any. After this, upon successful completion, use ChosenCommandName() to obtain the sub-command given in the command-line, and ChosenCommand() to get the flag.FlagSet corresponding to that command.
func (*FlagSubCommander) String ¶ added in v1.4.1
func (fsc *FlagSubCommander) String() string
Implements fmt.Stringer. Returns the list of defined subcommands. i.e. "foo,bar"
type StringsFlag ¶ added in v1.3.0
func RegisterSelectVar ¶ added in v1.3.0
func RegisterSelectVar(r *StringsFlag, name string, value string, usage string) *StringsFlag
func (*StringsFlag) Help ¶ added in v1.3.0
func (r *StringsFlag) Help() string
return the list of allowed values (choices) and default value
func (*StringsFlag) IsValid ¶ added in v1.3.0
func (r *StringsFlag) IsValid() bool
func (*StringsFlag) Set ¶ added in v1.3.0
func (r *StringsFlag) Set(value string) error
implements flag.Value
func (*StringsFlag) SetChoices ¶ added in v1.3.0
func (r *StringsFlag) SetChoices(choices []string) *StringsFlag
set the string choices that will be considered valid. Any other values will be rejected by Set(). Values will be lowercased.
func (*StringsFlag) Strict ¶ added in v1.3.0
func (r *StringsFlag) Strict(strict bool) *StringsFlag
when strict is set, the Set() function only accepts the values defined in SetChoices(), else it accepts any; thus behaving like a simple flag.StringVar
func (*StringsFlag) String ¶ added in v1.3.0
func (r *StringsFlag) String() string
implements flag.Value and fmt.Stringer