mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-15 23:26:36 +00:00
Fix: --strategies on CLI do not seem to override disabled-strategies in the manifest (#1857)
* Fix cli override in entry.rs Forward `args.disabled_strategies` Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Fix `args::parse`: Do not free disabled_strategies Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Fix passing of cli_overrides Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Create strategies-test-override-Cargo.toml Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Add e2e-tests for cli-overrides Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Fix entry.rs Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * fix entry.rs Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Fix entry.rs Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Update strategies.sh Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Compute cli_overrides in args::parse Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * fix use of args::parse main_impl.rs Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Update entry.rs Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Fix args::parse Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Fix typo in args.rs Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Fix args.rs Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Fix fmt in args.rs Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * fix fmt in main_impl.rs Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * update e2e-test-strategies Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Update e2e-tests/strategies.sh Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Update e2e-tests/strategies.sh Make sure both --strategies and --disable-strategies is tested Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Update strategies.sh Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> --------- Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
This commit is contained in:
parent
cdbb121112
commit
ee94b8b639
5 changed files with 47 additions and 18 deletions
|
@ -13,7 +13,7 @@ use binstalk::{
|
|||
ops::resolve::{CrateName, VersionReqExt},
|
||||
registry::Registry,
|
||||
};
|
||||
use binstalk_manifests::cargo_toml_binstall::Strategy;
|
||||
use binstalk_manifests::cargo_toml_binstall::{PkgOverride, Strategy};
|
||||
use clap::{builder::PossibleValue, error::ErrorKind, CommandFactory, Parser, ValueEnum};
|
||||
use compact_str::CompactString;
|
||||
use log::LevelFilter;
|
||||
|
@ -464,7 +464,7 @@ impl ValueEnum for StrategyWrapped {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse() -> Args {
|
||||
pub fn parse() -> (Args, PkgOverride) {
|
||||
// Filter extraneous arg when invoked by cargo
|
||||
// `cargo run -- --help` gives ["target/debug/cargo-binstall", "--help"]
|
||||
// `cargo binstall --help` gives ["/home/ryan/.cargo/bin/cargo-binstall", "binstall", "--help"]
|
||||
|
@ -561,6 +561,8 @@ You cannot use --{option} and specify multiple packages at the same time. Do one
|
|||
}
|
||||
}
|
||||
|
||||
let has_strategies_override = !opts.strategies.is_empty();
|
||||
|
||||
// Default strategies if empty
|
||||
if opts.strategies.is_empty() {
|
||||
opts.strategies = vec![
|
||||
|
@ -588,9 +590,6 @@ You cannot use --{option} and specify multiple packages at the same time. Do one
|
|||
.error(ErrorKind::TooFewValues, "You have disabled all strategies")
|
||||
.exit()
|
||||
}
|
||||
|
||||
// Free disable_strategies as it will not be used again.
|
||||
opts.disable_strategies = Vec::new();
|
||||
}
|
||||
|
||||
// Ensure that Strategy::Compile is specified as the last strategy
|
||||
|
@ -614,7 +613,23 @@ You cannot use --{option} and specify multiple packages at the same time. Do one
|
|||
_ => (),
|
||||
}
|
||||
|
||||
opts
|
||||
let cli_overrides = PkgOverride {
|
||||
pkg_url: opts.pkg_url.take(),
|
||||
pkg_fmt: opts.pkg_fmt.take(),
|
||||
bin_dir: opts.bin_dir.take(),
|
||||
disabled_strategies: (!opts.disable_strategies.is_empty() || has_strategies_override).then(
|
||||
|| {
|
||||
opts.disable_strategies
|
||||
.iter()
|
||||
.map(|strategy| strategy.0)
|
||||
.collect::<Vec<_>>()
|
||||
.into_boxed_slice()
|
||||
},
|
||||
),
|
||||
signing: None,
|
||||
};
|
||||
|
||||
(opts, cli_overrides)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue