Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var PrintHelpErr = errors.New("Refer to --help for usage information")
Return this error in [EntryPoint] to print help message and exit.
View Source
var PrintVersionErr = errors.New("--version")
Return this error in [EntryPoint] to print version message and exit.
Functions ¶
Types ¶
type Program ¶
type Program struct {
// The name of the binary/subcommand
Name string
// SemVer, e.g. 0.1.2-beta.1 (no 'v' prefix).
// Leave empty for subcommands.
Version string
// Brief description of the binary/subcommand.
Description string
// Pointer to a struct{} containing all options and flags.
//
// The struct{} must contain fields with the following datatypes allowed:
//
// int-s, uint-s, float-s, string, bool
//
// Each field can have the following tags:
//
// — alt:"" (Optional) This is a SINGLE character alternative to the option/flag.
//
// — desc:"" (Optional) A brief description of the option/flag.
//
// — default:"" (Optional) The default value of the flag.
Options any
// Pointer to a struct{} containing all positional arguments.
//
// The struct{} must contain fields with the following datatypes allowed:
//
// int-s, uint-s, float-s, string.
//
// Use slices to indicate variadic arguments, e.g. []string.
//
// NOTE: Only a single variadic argument is allowed and it must be in the end.
// NOTE: Variadic arguments are ALWAYS optional.
//
// Use pointers to indicate that the argument is optional, e.g. *string.
//
// NOTE: Optional arguments must be in the end.
Args any
// Commands are other sub-programs that have their own nested options and arguments.
//
// NOTE: Parent's .Options will be parsed and set up and until the command name is mentioned in the input.
Commands []*Program
// The function that will be called when running the Program.
//
// [rawArgs] contains positional input arguments. It is often more convinient to use provided [.Args] instead.
EntryPoint func(rawArgs []string) error
// contains filtered or unexported fields
}
func (*Program) HasVersion ¶
func (*Program) PrintVersion ¶
Click to show internal directories.
Click to hide internal directories.