Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't be used as a global flag, together with sub-commands. #33

Closed
cardil opened this issue Feb 9, 2022 · 1 comment · Fixed by #34
Closed

Can't be used as a global flag, together with sub-commands. #33

cardil opened this issue Feb 9, 2022 · 1 comment · Fixed by #34

Comments

@cardil
Copy link

cardil commented Feb 9, 2022

When using sub-commands it would be good idea to set this flag globally.

#[derive(Parser, Debug)]
pub(crate) struct Args {
  #[clap(subcommand)]
  command: Commands,
  #[clap(flatten, global = true)]
  verbose: Verbosity,
}

Above produces an error:

error: methods are not allowed for flattened entry
  --> src/cli/args.rs:24:10
   |
24 |   #[clap(flatten, global = true)]
   | 
epage added a commit to epage/clap-verbosity-flag that referenced this issue Feb 9, 2022
This will carry them across subcommands

Fixes clap-rs#33
@epage
Copy link
Member

epage commented Feb 9, 2022

Clap doesn't support attributes like this on a flatten because of the complexities of communicating between derives.

However, I've been meaning to hard code these flags to be global. #34 takes care of that.

@epage epage closed this as completed in #34 Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants