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 MultiArgsMap(args cli.ArgsParser, mapTgt 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"
ArgsCmdDefault to set option a default value
const ArgsCmdHelp = "help"
ArgsCmdHelp the help information of the option
const ArgsCmdRequired = "required"
ArgsCmdRequired the option of command is required
const ArgsCmdStructGen = "structGen"
ArgsCmdStructGen marking it requires parsing of substructure documents and values
const ArgsGlobalOwner = "globalOwner"
ArgsGlobalOwner as an identifier for global options
const ArgsOptionNoValid = "notValid"
ArgsOptionNoValid the command does not verify option data
const ArgsTagData = "isdata"
ArgsTagData as a mapping identifier for the data in the command
const ArgsTagMark = "mark" // tag option input values name
ArgsTagMark the option document is identified as the value of the option when it is generated
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"
ArgsTagNext as a command output data specific index, default index=1
const ArgsTagOmit = "-"
ArgsTagOmit ignore command line properties, that is, do not parse
const ArgsTagOwner = "owner"
ArgsTagOwner a tag in a structure command that is an option to the command it belongs to
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
MultiArgs(args cli.ArgsParser, target any, seq string='.', pref string=”): support all param like
func MultiArgsMap ¶
func MultiArgsMap(args cli.ArgsParser, mapTgt any, params ...string) error
MultiArgsMap Assign cli.ArgsParser to map
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