diff --git a/src/bin/add/args.rs b/src/bin/add/args.rs index 7e00a2295e..f5b0170935 100644 --- a/src/bin/add/args.rs +++ b/src/bin/add/args.rs @@ -108,21 +108,6 @@ pub struct Args { )] pub pkgid: Option, - /// Choose method of semantic version upgrade. Must be one of "none" (exact version, `=` - /// modifier), "patch" (`~` modifier), "minor" (`^` modifier), "all" (`>=`), or "default" (no - /// modifier). - #[clap( - long, - value_name = "METHOD", - possible_value = "none", - possible_value = "patch", - possible_value = "minor", - possible_value = "all", - possible_value = "default", - default_value = "default" - )] - pub upgrade: String, - /// Include prerelease versions when fetching from crates.io (e.g. /// '0.6.0-alpha'). #[clap(long)] @@ -223,11 +208,8 @@ impl Args { p.manifest_path.parent().map(|p| p.as_std_path()) == Some(dep_path.as_path()) }) { - let v = format!( - "{prefix}{version}", - prefix = self.get_upgrade_prefix(), - version = package.version - ); + let op = ""; + let v = format!("{op}{version}", op = op, version = package.version); dependency = dependency.set_version(&v); } @@ -283,11 +265,8 @@ impl Args { ); // dev-dependencies do not need the version populated if !self.dev { - let v = format!( - "{prefix}{version}", - prefix = self.get_upgrade_prefix(), - version = package.version - ); + let op = ""; + let v = format!("{op}{version}", op = op, version = package.version); dependency = dependency.set_version(&v); } } else { @@ -297,9 +276,10 @@ impl Args { &manifest_path, Some(®istry_url), )?; + let op = ""; let v = format!( - "{prefix}{version}", - prefix = self.get_upgrade_prefix(), + "{op}{version}", + op = op, // If version is unavailable `get_latest_dependency` must have // returned `Err(FetchVersionError::GetVersion)` version = dependency.version().unwrap_or_else(|| unreachable!()) @@ -357,17 +337,6 @@ impl Args { }) .collect() } - - fn get_upgrade_prefix(&self) -> &'static str { - match self.upgrade.as_ref() { - "default" => "", - "none" => "=", - "patch" => "~", - "minor" => "^", - "all" => ">=", - _ => unreachable!(), - } - } } #[cfg(test)] @@ -388,7 +357,6 @@ impl Default for Args { optional: false, manifest_path: None, pkgid: None, - upgrade: "minor".to_string(), allow_prerelease: false, features: None, no_default_features: false, diff --git a/tests/cmd/add/dev_build_conflict.toml b/tests/cmd/add/dev_build_conflict.toml index c29cefa8fd..cf81360e9f 100644 --- a/tests/cmd/add/dev_build_conflict.toml +++ b/tests/cmd/add/dev_build_conflict.toml @@ -6,7 +6,7 @@ stderr = """ error: The argument '--dev' cannot be used with '--build' USAGE: - cargo add --dev --upgrade ... + cargo add --dev ... For more information try --help """ diff --git a/tests/cmd/add/git_conflicts_path.toml b/tests/cmd/add/git_conflicts_path.toml index 7a5bf2e439..6afdbf1cc2 100644 --- a/tests/cmd/add/git_conflicts_path.toml +++ b/tests/cmd/add/git_conflicts_path.toml @@ -6,7 +6,7 @@ stderr = """ error: The argument '--git ' cannot be used with '--path ' USAGE: - cargo add --git --upgrade ... + cargo add --git ... For more information try --help """ diff --git a/tests/cmd/add/git_conflicts_registry.toml b/tests/cmd/add/git_conflicts_registry.toml index aad49f526b..fea5d34197 100644 --- a/tests/cmd/add/git_conflicts_registry.toml +++ b/tests/cmd/add/git_conflicts_registry.toml @@ -6,7 +6,7 @@ stderr = """ error: The argument '--git ' cannot be used with '--registry ' USAGE: - cargo add --git --upgrade ... + cargo add --git ... For more information try --help """ diff --git a/tests/cmd/add/git_conflicts_vers.toml b/tests/cmd/add/git_conflicts_vers.toml index fc935c75ff..25561fc8ef 100644 --- a/tests/cmd/add/git_conflicts_vers.toml +++ b/tests/cmd/add/git_conflicts_vers.toml @@ -6,7 +6,7 @@ stderr = """ error: The argument '--git ' cannot be used with '--vers ' USAGE: - cargo add --git --upgrade ... + cargo add --git ... For more information try --help """ diff --git a/tests/cmd/add/invalid_op.in b/tests/cmd/add/invalid_op.in deleted file mode 120000 index 87eae14531..0000000000 --- a/tests/cmd/add/invalid_op.in +++ /dev/null @@ -1 +0,0 @@ -add-basic.in/ \ No newline at end of file diff --git a/tests/cmd/add/invalid_op.out/Cargo.toml b/tests/cmd/add/invalid_op.out/Cargo.toml deleted file mode 100644 index 5e20016d71..0000000000 --- a/tests/cmd/add/invalid_op.out/Cargo.toml +++ /dev/null @@ -1,3 +0,0 @@ -[package] -name = "cargo-list-test-fixture" -version = "0.0.0" diff --git a/tests/cmd/add/invalid_op.toml b/tests/cmd/add/invalid_op.toml deleted file mode 100644 index 94264f53e6..0000000000 --- a/tests/cmd/add/invalid_op.toml +++ /dev/null @@ -1,17 +0,0 @@ -bin.name = "cargo-add" -args = ["add", "my-package", "--upgrade=an_invalid_string"] -status.code = 2 -stdout = "" -stderr = """ -error: \"an_invalid_string\" isn't a valid value for '--upgrade ' -\t[possible values: all, default, minor, none, patch] - -USAGE: - cargo add --upgrade ... - -For more information try --help -""" -fs.sandbox = true - -[env.add] -CARGO_IS_TEST="1" diff --git a/tests/cmd/add/invalid_optional_dev.in b/tests/cmd/add/invalid_optional_dev.in deleted file mode 120000 index 87eae14531..0000000000 --- a/tests/cmd/add/invalid_optional_dev.in +++ /dev/null @@ -1 +0,0 @@ -add-basic.in/ \ No newline at end of file diff --git a/tests/cmd/add/invalid_optional_dev.out/Cargo.toml b/tests/cmd/add/invalid_optional_dev.out/Cargo.toml deleted file mode 100644 index 5e20016d71..0000000000 --- a/tests/cmd/add/invalid_optional_dev.out/Cargo.toml +++ /dev/null @@ -1,3 +0,0 @@ -[package] -name = "cargo-list-test-fixture" -version = "0.0.0" diff --git a/tests/cmd/add/invalid_optional_dev.toml b/tests/cmd/add/invalid_optional_dev.toml deleted file mode 100644 index 95ffec9ba6..0000000000 --- a/tests/cmd/add/invalid_optional_dev.toml +++ /dev/null @@ -1,16 +0,0 @@ -bin.name = "cargo-add" -args = ["add", "my-package", "--optional", "--dev"] -status.code = 2 -stdout = "" -stderr = """ -error: The argument '--optional' cannot be used with '--dev' - -USAGE: - cargo add --optional --upgrade ... - -For more information try --help -""" -fs.sandbox = true - -[env.add] -CARGO_IS_TEST="1" diff --git a/tests/cmd/add/op_caret.in b/tests/cmd/add/op_caret.in deleted file mode 120000 index 87eae14531..0000000000 --- a/tests/cmd/add/op_caret.in +++ /dev/null @@ -1 +0,0 @@ -add-basic.in/ \ No newline at end of file diff --git a/tests/cmd/add/op_caret.out/Cargo.toml b/tests/cmd/add/op_caret.out/Cargo.toml deleted file mode 100644 index 82754dcf89..0000000000 --- a/tests/cmd/add/op_caret.out/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "cargo-list-test-fixture" -version = "0.0.0" - -[dependencies] -my-package = "^99999.0.0" diff --git a/tests/cmd/add/op_caret.toml b/tests/cmd/add/op_caret.toml deleted file mode 100644 index e809ef9237..0000000000 --- a/tests/cmd/add/op_caret.toml +++ /dev/null @@ -1,11 +0,0 @@ -bin.name = "cargo-add" -args = ["add", "my-package", "--upgrade", "minor"] -status = "success" -stdout = "" -stderr = """ - Adding my-package ^99999.0.0 to dependencies. -""" -fs.sandbox = true - -[env.add] -CARGO_IS_TEST="1" diff --git a/tests/cmd/add/op_equal.in b/tests/cmd/add/op_equal.in deleted file mode 120000 index 87eae14531..0000000000 --- a/tests/cmd/add/op_equal.in +++ /dev/null @@ -1 +0,0 @@ -add-basic.in/ \ No newline at end of file diff --git a/tests/cmd/add/op_equal.out/Cargo.toml b/tests/cmd/add/op_equal.out/Cargo.toml deleted file mode 100644 index 20e02b92f7..0000000000 --- a/tests/cmd/add/op_equal.out/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "cargo-list-test-fixture" -version = "0.0.0" - -[dependencies] -my-package = "=99999.0.0" diff --git a/tests/cmd/add/op_equal.toml b/tests/cmd/add/op_equal.toml deleted file mode 100644 index f1e1697cd7..0000000000 --- a/tests/cmd/add/op_equal.toml +++ /dev/null @@ -1,11 +0,0 @@ -bin.name = "cargo-add" -args = ["add", "my-package", "--upgrade", "none"] -status = "success" -stdout = "" -stderr = """ - Adding my-package =99999.0.0 to dependencies. -""" -fs.sandbox = true - -[env.add] -CARGO_IS_TEST="1" diff --git a/tests/cmd/add/op_greater_eq.in b/tests/cmd/add/op_greater_eq.in deleted file mode 120000 index 87eae14531..0000000000 --- a/tests/cmd/add/op_greater_eq.in +++ /dev/null @@ -1 +0,0 @@ -add-basic.in/ \ No newline at end of file diff --git a/tests/cmd/add/op_greater_eq.out/Cargo.toml b/tests/cmd/add/op_greater_eq.out/Cargo.toml deleted file mode 100644 index 0d397d55c4..0000000000 --- a/tests/cmd/add/op_greater_eq.out/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "cargo-list-test-fixture" -version = "0.0.0" - -[dependencies] -my-package = ">=99999.0.0" diff --git a/tests/cmd/add/op_greater_eq.toml b/tests/cmd/add/op_greater_eq.toml deleted file mode 100644 index c48c799df1..0000000000 --- a/tests/cmd/add/op_greater_eq.toml +++ /dev/null @@ -1,11 +0,0 @@ -bin.name = "cargo-add" -args = ["add", "my-package", "--upgrade", "all"] -status = "success" -stdout = "" -stderr = """ - Adding my-package >=99999.0.0 to dependencies. -""" -fs.sandbox = true - -[env.add] -CARGO_IS_TEST="1" diff --git a/tests/cmd/add/op_tilde.in b/tests/cmd/add/op_tilde.in deleted file mode 120000 index 87eae14531..0000000000 --- a/tests/cmd/add/op_tilde.in +++ /dev/null @@ -1 +0,0 @@ -add-basic.in/ \ No newline at end of file diff --git a/tests/cmd/add/op_tilde.out/Cargo.toml b/tests/cmd/add/op_tilde.out/Cargo.toml deleted file mode 100644 index 8a4d10f647..0000000000 --- a/tests/cmd/add/op_tilde.out/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "cargo-list-test-fixture" -version = "0.0.0" - -[dependencies] -my-package = "~99999.0.0" diff --git a/tests/cmd/add/op_tilde.toml b/tests/cmd/add/op_tilde.toml deleted file mode 100644 index 1312e81c37..0000000000 --- a/tests/cmd/add/op_tilde.toml +++ /dev/null @@ -1,11 +0,0 @@ -bin.name = "cargo-add" -args = ["add", "my-package", "--upgrade", "patch"] -status = "success" -stdout = "" -stderr = """ - Adding my-package ~99999.0.0 to dependencies. -""" -fs.sandbox = true - -[env.add] -CARGO_IS_TEST="1" diff --git a/tests/cmd/add/registry_conflicts_path.toml b/tests/cmd/add/registry_conflicts_path.toml index 44263fd1d5..c2f4961c87 100644 --- a/tests/cmd/add/registry_conflicts_path.toml +++ b/tests/cmd/add/registry_conflicts_path.toml @@ -6,7 +6,7 @@ stderr = """ error: The argument '--registry ' cannot be used with '--path ' USAGE: - cargo add --registry --upgrade ... + cargo add --registry ... For more information try --help """