clap
                                
                                
                                
                                    clap copied to clipboard
                            
                            
                            
                        derive error for missing `= value` for attributes is confusing
Please complete the following tasks
- [X] I have searched the discussions
 - [X] I have searched the open and rejected issues
 
Clap Version
3.1.18
Describe your use case
I'm trying to add an environment variable fallback for the --password option. I do not want the variable value to be accidentally revealed when --help is used.
I tried to write
#[clap(short, long, env = "PROGRAM_PASSWORD", hide_env_values)]
password: Option<String>,
but the error made me think that the attribute doesn't exist when it does:
error: unexpected attribute: hide_env_values
(Note: #3620 is for bool shorthand support)
Describe the solution you'd like
A clearer error message
Alternatives, if applicable
Additional Context
No response
Boolean builder functions do not have an implied  = true but you have to set it manually.  The following should work
#[clap(short, long, env = "PROGRAM_PASSWORD", hide_env_values = true)]
password: Option<String>,
See https://github.com/clap-rs/clap/issues/3620
Thanks! I should've tried that before opening an issue :face_exhaling:
I was getting
error: unexpected attribute: hide_env_values
when compiling, and it is not mentioned anywhere in the documentation, so I just assumed that this attribute was not implemented.
Thats an artifact of how we parse the attributes.  It isn't in our hard coded list of attributes that work without a = or ().  It would be nice to improve that message but unsure what to say.
Would you be opposed to adding the boolean attributes to the list that are accepted without a value? I imagine they all could be treated as true, but I would go through them and check. (To be clear, I’m volunteering.)
Otherwise, I suppose the error could be something like:
error: unexpected attribute without value: hide_env_values
I‘m not sure how much clearer that is, though.
@danielparks see https://github.com/clap-rs/clap/issues/3620