gen

package
v2.0.0-rc.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package gen Command line related generators, such as command to struct mappings

Index

Constants

View Source
const ArgsCmdDefault = "default"
View Source
const ArgsCmdHelp = "help"
View Source
const ArgsCmdRequired = "required"
View Source
const ArgsGlobalOwner = "globalOwner"
View Source
const ArgsOptionNoValid = "notValid"
View Source
const ArgsTagData = "isdata"
View Source
const ArgsTagMark = "mark" // tag option input values name
View Source
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".

View Source
const ArgsTagNext = "next"
View Source
const ArgsTagOmit = "-"
View Source
const ArgsTagOwner = "owner"

Variables

This section is empty.

Functions

func ArgsDecompose

func ArgsDecompose(data any, excludes ...string) ([]cli.Option, error)

ArgsDecompose Decompose the structure into an option list

func ArgsDecomposeMust

func ArgsDecomposeMust(data any, excludes ...string) []cli.Option

func ArgsDress

func ArgsDress(args cli.ArgsParser, data any) error

ArgsDress Dress the command argument up on the specified data entity (struct)

func AsCommand

func AsCommand(vStruct any, cfgs ...cli.Config) cli.Application[any]

func MultiArgs

func MultiArgs(args cli.ArgsParser, target any, params ...string) error

MultiArgs Multi Args value parsing

func OptionTagParse

func OptionTagParse(vTag string) *cli.Option

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"`

func StructDress

func StructDress(vStruct reflect.Value, excludes ...string) (inheritOpts []cli.Option)

StructDress dress up the struct property value (which supports composition/inheritance) on `cli.Option`

Types

type Runnable

type Runnable interface {
	cli.Fn | func()
}

type StructCmd

type StructCmd struct {
	// contains filtered or unexported fields
}

func ParseStruct

func ParseStruct(vStruct any) *StructCmd

func (*StructCmd) GetOptions

func (s *StructCmd) GetOptions(cmd string) *StructCmdAttr

func (*StructCmd) Index

func (s *StructCmd) Index() any

func (*StructCmd) Init

func (s *StructCmd) Init() any

func (*StructCmd) Lost

func (s *StructCmd) Lost() any

func (*StructCmd) SetArgs

func (s *StructCmd) SetArgs(args cli.ArgsParser)

SetArgs 设置option

type StructCmdAttr

type StructCmdAttr struct {
	ChildOption []cli.Option
	Option      cli.Option
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL