Skip to content

Commit ff308c0

Browse files
inhereclaude
andcommitted
feat(gflag): 增加 CliOpt.TypeName() 类型名访问器
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0b1ad99 commit ff308c0

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

gflag/opts.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,10 @@ type CliOpt struct {
684684
// useful for shell completion to decide value-completion vs command-completion.
685685
func (m *CliOpt) TakesValue() bool { return m.flagType != FlagTypeBool }
686686

687+
// TypeName get the flag type name. eg: bool, string, int, float, var, func
688+
// 公开已有的私有 flagType 字段, 供文档生成等场景读取选项类型。
689+
func (m *CliOpt) TypeName() string { return m.flagType }
690+
687691
// NewOpt quick create an CliOpt instance
688692
func NewOpt(nameAndShorts, desc string, defVal any, setFns ...CliOptFn) *CliOpt {
689693
return newOpt(nameAndShorts, desc, defVal, "", setFns...)

0 commit comments

Comments
 (0)