mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 21:48:42 +00:00
Simplify args::parse
using clap::Arg::conflicts_with
(#1198)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
9d4694219b
commit
65670224b8
1 changed files with 7 additions and 27 deletions
|
@ -101,7 +101,7 @@ pub struct Args {
|
||||||
/// runs as if `--manifest-path $cloned_repo` is passed to binstall.
|
/// runs as if `--manifest-path $cloned_repo` is passed to binstall.
|
||||||
///
|
///
|
||||||
/// This option cannot be used with `--manifest-path`.
|
/// This option cannot be used with `--manifest-path`.
|
||||||
#[clap(help_heading = "Overrides", long)]
|
#[clap(help_heading = "Overrides", long, conflicts_with("manifest_path"))]
|
||||||
pub git: Option<binstalk::helpers::git::GitUrl>,
|
pub git: Option<binstalk::helpers::git::GitUrl>,
|
||||||
|
|
||||||
/// Override Cargo.toml package manifest bin-dir.
|
/// Override Cargo.toml package manifest bin-dir.
|
||||||
|
@ -242,7 +242,12 @@ pub struct Args {
|
||||||
/// reading from `registries.<name>.index`.
|
/// reading from `registries.<name>.index`.
|
||||||
///
|
///
|
||||||
/// Cannot be used with `--index`.
|
/// Cannot be used with `--index`.
|
||||||
#[clap(help_heading = "Options", long, env = "CARGO_REGISTRY_DEFAULT")]
|
#[clap(
|
||||||
|
help_heading = "Options",
|
||||||
|
long,
|
||||||
|
env = "CARGO_REGISTRY_DEFAULT",
|
||||||
|
conflicts_with("index")
|
||||||
|
)]
|
||||||
pub registry: Option<CompactString>,
|
pub registry: Option<CompactString>,
|
||||||
|
|
||||||
/// This option will be passed through to all `cargo-install` invocations.
|
/// This option will be passed through to all `cargo-install` invocations.
|
||||||
|
@ -426,31 +431,6 @@ pub fn parse() -> Args {
|
||||||
// Ensure no conflict
|
// Ensure no conflict
|
||||||
let mut command = Args::command();
|
let mut command = Args::command();
|
||||||
|
|
||||||
#[cfg(feature = "git")]
|
|
||||||
if opts.manifest_path.is_some() && opts.git.is_some() {
|
|
||||||
command
|
|
||||||
.error(
|
|
||||||
ErrorKind::ArgumentConflict,
|
|
||||||
format_args!(
|
|
||||||
r#"Multiple override options for Cargo.toml fetching.
|
|
||||||
You cannot use --manifest-path and --git. Do one or the other."#
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if opts.index.is_some() && opts.registry.is_some() {
|
|
||||||
command
|
|
||||||
.error(
|
|
||||||
ErrorKind::ArgumentConflict,
|
|
||||||
format_args!(
|
|
||||||
r#"Multiple override options for registry.
|
|
||||||
You cannot use --index and --registry. Do one or the other."#
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if opts.crate_names.len() > 1 {
|
if opts.crate_names.len() > 1 {
|
||||||
let option = if opts.version_req.is_some() {
|
let option = if opts.version_req.is_some() {
|
||||||
"version"
|
"version"
|
||||||
|
|
Loading…
Add table
Reference in a new issue