clitag

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTagName = "cli"

DefaultTagName ftagのデフォルト名

Variables

View Source
var DefaultParser = &Parser{Config: &ParserConfig{TagName: DefaultTagName}}

Functions

This section is empty.

Types

type Parser

type Parser struct {
	Config *ParserConfig
}

Parser ftagのパーサー

func (*Parser) Parse

func (p *Parser) Parse(v interface{}) ([]StructField, error)

Parse ftagをパースする

func (*Parser) ParseField

func (p *Parser) ParseField(parent StructField, f reflect.StructField) ([]StructField, error)

func (*Parser) ParseFields

func (p *Parser) ParseFields(parent StructField, tp reflect.Type) ([]StructField, error)

type ParserConfig

type ParserConfig struct {
	TagName    string
	OptionsMap map[string][]string // 指定可能な値(オプション)参照用のマップ
}

ParserConfig パーサ設定

type StructField

type StructField struct {
	reflect.StructField
	Tag
}

Field reflect.StructField + Tag

func Parse

func Parse(v interface{}) ([]StructField, error)

Parse デフォルトのParser(タグ名:cli)でftagをパースする

type Tag

type Tag struct {
	FlagName       string
	FieldName      string
	Aliases        []string
	Shorthand      string
	Description    string
	Squash         bool
	Ignore         bool
	Category       string
	Order          int
	Options        []string // 設定可能な値のリスト
	DisplayOptions []string // 表示用
}

Tag structにつけられたftagの値

例: タグが`example,aliases=foo bar,short=e,desc=foobar`の場合 - FlagName: example - Aliases: foo, bar - Shorthand: e - Description: foobar - Squash: false - Ignore: false - Category: (empty) - Order: 0

func (Tag) AliasesString

func (t Tag) AliasesString() string

func (Tag) LongDescription

func (t Tag) LongDescription() string

LongDescription DescriptionにAliasesとOptionsを連結して返す

func (Tag) OptionsString

func (t Tag) OptionsString() string

Jump to

Keyboard shortcuts

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