Skip to content

Get Flag type and required status #1845

Answered by dearchap
xoxys asked this question in Q&A
Dec 21, 2023 · 1 comments · 6 replies
Discussion options

You must be logged in to vote

required is easy. You can check if rf, ok := f.(cli.RequiredFlag); ok && rf.IsRequired(). The type is not easy as that isnt exported anywhere. You can use the golang reflect to get the actual type and that would give you cli.BoolFlag or cli.IntFlag etc etc.

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@xoxys
Comment options

@dearchap
Comment options

@xoxys
Comment options

@dearchap
Comment options

Answer selected by xoxys
@xoxys
Comment options

@dearchap
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants