1use clap::{Parser, Subcommand};
2
3#[derive(Parser, Debug)]
4#[command(name = "cargo")]
5#[command(bin_name = "cargo")]
6pub struct CargoCli {
7 #[command(subcommand)]
8 pub command: CargoSubcommand,
9}
10
11#[derive(Subcommand, Debug)]
12pub enum CargoSubcommand {
13 #[command(name = "test-filter")]
14 TestFilter(TestFilterArgs),
15}
16
17#[derive(Parser, Debug)]
19#[command(author, version, about, long_about = None)]
20pub struct TestFilterArgs {
21 #[arg(long, conflicts_with = "unit")]
23 pub integration: bool,
24
25 #[arg(long, conflicts_with = "integration")]
27 pub unit: bool,
28
29 #[arg(long, value_delimiter = ',')]
31 pub tag: Vec<String>,
32
33 #[arg(long, value_delimiter = ',')]
35 pub exclude_tag: Vec<String>,
36
37 #[arg(long)]
39 pub name: Option<String>,
40
41 #[arg(long)]
43 pub path: Option<String>,
44
45 #[arg(long)]
47 pub timeout: Option<u64>,
48
49 #[arg(long)]
51 pub list: bool,
52
53 #[arg(short, long)]
55 pub verbose: bool,
56
57 #[arg(trailing_var_arg = true, allow_hyphen_values = true)]
59 pub test_args: Vec<String>,
60}
61
62impl TestFilterArgs {
63 pub fn has_filters(&self) -> bool {
65 self.integration
66 || self.unit
67 || !self.tag.is_empty()
68 || !self.exclude_tag.is_empty()
69 || self.name.is_some()
70 || self.path.is_some()
71 }
72}