1use std::path::PathBuf;
6
7use clap::{ArgGroup, Parser};
8
9use crate::command::Command;
10
11#[derive(Parser, Clone, PartialEq, Eq, Debug)]
12#[command(version = env!("CARGO_PKG_VERSION"))]
13pub struct App {
14 #[arg(hide = true, value_parser = clap::builder::PossibleValuesParser::new(["modules"]))]
15 pub dummy: Option<String>,
16
17 #[command(subcommand)]
18 pub command: Command,
19}
20
21impl App {
22 pub fn sanitized_command(self) -> Command {
23 let mut command = self.command;
24 command.sanitize();
25 command
26 }
27}
28
29#[derive(Parser, Clone, PartialEq, Eq, Debug)]
30#[group(id = "ProjectOptions")]
31#[command(group = ArgGroup::new("target-group"))]
32pub struct ProjectOptions {
33 #[arg(long = "lib", group = "target-group")]
35 pub lib: bool,
36
37 #[arg(long = "bin", group = "target-group")]
39 pub bin: Option<String>,
40
41 #[arg(short = 'p', long = "package")]
43 pub package: Option<String>,
44
45 #[arg(long = "no-default-features")]
47 pub no_default_features: bool,
48
49 #[arg(long = "all-features")]
51 pub all_features: bool,
52
53 #[arg(long = "features")]
56 pub features: Vec<String>,
57
58 #[arg(long = "target")]
60 pub target: Option<String>,
61
62 #[arg(long = "manifest-path", default_value = ".")]
64 pub manifest_path: PathBuf,
65}
66
67#[derive(Parser, Clone, PartialEq, Eq, Debug)]
68#[group(id = "GeneralOptions")]
69pub struct GeneralOptions {
70 #[arg(long = "verbose")]
72 pub verbose: bool,
73}