cargo_modules/
options.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5use 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    /// Process only this package's library.
34    #[arg(long = "lib", group = "target-group")]
35    pub lib: bool,
36
37    /// Process only the specified binary.
38    #[arg(long = "bin", group = "target-group")]
39    pub bin: Option<String>,
40
41    /// Package to process (see `cargo help pkgid`).
42    #[arg(short = 'p', long = "package")]
43    pub package: Option<String>,
44
45    /// Do not activate the `default` feature.
46    #[arg(long = "no-default-features")]
47    pub no_default_features: bool,
48
49    /// Activate all available features.
50    #[arg(long = "all-features")]
51    pub all_features: bool,
52
53    /// List of features to activate.
54    /// This will be ignored if `--cargo-all-features` is provided.
55    #[arg(long = "features")]
56    pub features: Vec<String>,
57
58    /// Analyze for target triple.
59    #[arg(long = "target")]
60    pub target: Option<String>,
61
62    /// Path to Cargo.toml.
63    #[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    /// Use verbose output.
71    #[arg(long = "verbose")]
72    pub verbose: bool,
73}