Skip to content

How to use requires_if in derive? #5339

Answered by epage
yift asked this question in Q&A
Feb 3, 2024 · 2 comments · 4 replies
Discussion options

You must be logged in to vote

Next time, I'd recommend

  • Making the example a little less generic so its easier to talk about the cases
  • Specifying what and why for unexpected

If I'm understanding what you are talking about, you are looking at

#!/usr/bin/env nargo
---
[dependencies]
clap = { path = "../clap", features = ["derive"] }
---

use clap::Parser;

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
/// blas ccc
struct Cli {
    /// one
    #[arg(short, long, value_parser = ["raw", "json"])]
    format: String,

    /// test
    #[arg(short, long, value_parser = ["short", "pretty"])]
    json_style: Option<String>,
}
fn parse_and_print(args: Vec<&str>) {
    println!("Parsing: {:?}", …

Replies: 2 comments 4 replies

Comment options

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

@yift
Comment options

@epage
Comment options

Answer selected by yift
Comment options

You must be logged in to vote
1 reply
@epage
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