Skip to content

Is there an easy way to toggle the Required attribute of a cli.Flag ? #1329

@zhiqiangxu

Description

@zhiqiangxu

Now I have to create separate cli.Flag flag instances for Required and Optional, which is quite tedious:

// HeightFlag ...
var HeightFlag = cli.IntFlag{
	Name:     "height",
	Usage:    "specify height",
	Required: true,
}

// OptionalHeightFlag ...
var OptionalHeightFlag = cli.IntFlag{
	Name:  "height",
	Usage: "specify optional height",
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/v2relates to / is being considered for v2kind/questionsomeone asking a questionstatus/triagemaintainers still need to look into this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions