Documentation ¶
Overview ¶
Package gen Command line related generators, such as command to struct mappings
Index ¶
- Constants
- func ArgsDecompose(data any, excludes ...string) ([]cli.Option, error)
- func ArgsDecomposeMust(data any, excludes ...string) []cli.Option
- func ArgsDress(args cli.ArgsParser, data any) error
- func AsCommand(vStruct any, cfgs ...cli.Config) cli.Application[any]
- func MultiArgs(args cli.ArgsParser, target any, params ...string) error
- func OptionTagParse(vTag string) *cli.Option
- func StructDress(vStruct reflect.Value, excludes ...string) (inheritOpts []cli.Option)
- type Runnable
- type StructCmd
- type StructCmdAttr
Constants ¶
const ArgsCmdDefault = "default"
const ArgsCmdHelp = "help"
const ArgsCmdRequired = "required"
const ArgsGlobalOwner = "globalOwner"
const ArgsOptionNoValid = "notValid"
const ArgsTagData = "isdata"
const ArgsTagMark = "mark" // tag option input values name
const ArgsTagName = "cmd"
ArgsTagName The struct tag is named cmd. If this parameter is not set, the struct tag is divided into lowercase cases, such as file_name, make_up.
json tag is also supported when cmd is not set.
syntax rules of name: "cmd>>json>>FileName".
const ArgsTagNext = "next"
const ArgsTagOmit = "-"
const ArgsTagOwner = "owner"
Variables ¶
This section is empty.
Functions ¶
func ArgsDecompose ¶
ArgsDecompose Decompose the structure into an option list
func ArgsDress ¶
func ArgsDress(args cli.ArgsParser, data any) error
ArgsDress Dress the command argument up on the specified data entity (struct)
func MultiArgs ¶
func MultiArgs(args cli.ArgsParser, target any, params ...string) error
MultiArgs Multi Args value parsing
func OptionTagParse ¶
OptionTagParse Resolves the value of the tag into an option object
syntax rules of tag: `"name,n required default:111 help:help msg"`.
When using command data instead of options, you can specify `next` or default `subCommand`.
`"input isdata next:2"`
Types ¶
type StructCmd ¶
type StructCmd struct {
// contains filtered or unexported fields
}
func ParseStruct ¶
func (*StructCmd) GetOptions ¶
func (s *StructCmd) GetOptions(cmd string) *StructCmdAttr