Skip to content

How to define a flag with a way to check if the flag was provided on the command line? #5810

Answered by epage
donatello asked this question in Q&A
Discussion options

You must be logged in to vote

If you don't care about None but ok with false, you can do

    #[arg(short = 'k', long, env = "APP_INSECURE")]
    pub insecure: bool,

If you really need None, then that is the way to do it. The one change I would make is I would do num_args=0

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@donatello
Comment options

@donatello
Comment options

@epage
Comment options

epage Nov 7, 2024
Maintainer

Answer selected by donatello
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