check this code: #[derive(Parser, Debug)] #[command(version, about, longabout = None)]…
- User
check this code:
#[derive(Parser, Debug)] #[command(version, about, long_about = None)] pub struct Cli { #[command(subcommand)] pub command: DeintronizeTools,
#[arg( short = 't', long = "threads", help = "Number of threads", value_name = "THREADS", default_value_t = num_cpus::get() )] pub threads: usize,}
#[derive(Debug, Subcommand)] pub enum DeintronizeTools { #[command(name = "intron")] Intron { #[command(flatten)] args: IntronArgs, }, #[command(name = "fivend")] FiveEnd { #[command(flatten)] args: FiveEndArgs, }, }
why when I run: cargo run --release intron --ref ... --query ... -t I got this error:
error: unexpected argument '-t' found
Usage: deintronize intron [OPTIONS] --ref ... --query
For more information, try '--help'
- Assistant
The issue you're encountering appears to be related to where the
-t(or--threads) option is expected in the argument list, based on the structure of your command-line parsing code.In your
Clistruct, you have defined thethreadsargument at the top level, which suggests that it should be parsed before any subcommands (DeintronizeTools). However, it looks like you're trying to use the-toption after specifying a subcommand (intron), which is why it's not recognized in the position you've placed it.The
claplibrary, assuming you're using it given the syntax of your code, parses arguments based on the order and hierarchy defined in your code. Since is defined at the root level of your CLI structure, it expects it to appear before any subcommands.