#![allow(clippy::bool_assert_comparison)]
use cargo_edit::CargoResult;
use clap::Args;
#[derive(Debug, Args)]
#[command(version)]
#[command(after_help = "\
Examples:
$ cargo add regex --build
$ cargo add trycmd --dev
$ cargo add ./crate/parser/
$ cargo add serde +derive serde_json
")]
#[command(override_usage = "\
cargo add [OPTIONS] <DEP>[@<VERSION>] [+<FEATURE>,...] ...
cargo add [OPTIONS] <DEP_PATH> [+<FEATURE>,...] ...")]
pub struct AddArgs {
#[arg(value_name = "DEP_ID")]
pub crates: Vec<String>,
#[arg(long)]
no_default_features: bool,
#[arg(long, overrides_with = "no_default_features")]
default_features: bool,
#[arg(short = 'F', long)]
pub features: Option<Vec<String>>,
#[arg(long, conflicts_with = "dev")]
pub optional: bool,
#[arg(long, conflicts_with = "dev", overrides_with = "optional")]
pub no_optional: bool,
#[arg(long, short)]
pub rename: Option<String>,
#[arg(long, conflicts_with = "git")]
pub registry: Option<String>,
#[arg(short = 'D', long, help_heading = "Section", group = "section")]
pub dev: bool,
#[arg(short = 'B', long, help_heading = "Section", group = "section")]
pub build: bool,
#[arg(long, help_heading = "Section", group = "section")]
pub target: Option<String>,
#[arg(long, value_name = "PATH")]
pub manifest_path: Option<std::path::PathBuf>,
#[arg(short = 'p', long = "package", value_name = "PKGID")]
pub pkgid: Option<String>,
#[arg(long)]
pub offline: bool,
#[arg(long)]
pub dry_run: bool,
#[arg(long)]
pub quiet: bool,
#[arg(long, value_name = "URI", help_heading = "Unstable")]
pub git: Option<String>,
#[arg(
long,
value_name = "BRANCH",
help_heading = "Unstable",
requires = "git",
group = "git-ref"
)]
pub branch: Option<String>,
#[arg(
long,
value_name = "TAG",
help_heading = "Unstable",
requires = "git",
group = "git-ref"
)]
pub tag: Option<String>,
#[arg(
long,
value_name = "REV",
help_heading = "Unstable",
requires = "git",
group = "git-ref"
)]
pub rev: Option<String>,
}
impl AddArgs {
pub fn exec(self) -> CargoResult<()> {
anyhow::bail!(
"`cargo add` has been merged into cargo 1.62+ as of cargo-edit 0.10, either
- Upgrade cargo, like with `rustup update`
- Downgrade `cargo-edit`, like with `cargo install cargo-edit --version 0.9.1`"
);
}
}