Feature: Impl opt-out options (#510)

Fixed #136

* Impl opt-out optioins in binstalk
* Replace field `Options::{gh_crate, quickinstall}_fetcher` with `resolver`
  which can determine order of resolver used.
* Add new field `Args::{disable_}strategies`
* Add new variant `BinstallError::InvalidStrategies`
* Add variant `BinstallError::NoFallbackToCargoInstall`
* Add code for supporting strategies in mod entry
* Test `--disable-strategies` in `tests.sh`
* Test for `--strategies` in `tests.sh`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-11-11 16:24:46 +11:00 committed by GitHub
parent 89fa5b1769
commit 9e80cf0700
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 141 additions and 11 deletions

View file

@ -129,6 +129,19 @@ pub struct Args {
#[clap(help_heading = "Overrides", long, default_value_t = RateLimit::default())]
pub rate_limit: RateLimit,
/// Specify the strategies to be used,
/// binstall will run the strategies specified in order.
///
/// Default value is "crate-meta-data,quick-install,compile".
#[clap(help_heading = "Overrides", long, value_delimiter(','))]
pub strategies: Vec<Strategy>,
/// Disable the strategies specified.
/// If a strategy is specified in `--strategies` and `--disable-strategies`,
/// then it will be removed.
#[clap(help_heading = "Overrides", long, value_delimiter(','))]
pub disable_strategies: Vec<Strategy>,
/// Disable symlinking / versioned updates.
///
/// By default, Binstall will install a binary named `<name>-<version>` in the install path, and
@ -282,6 +295,18 @@ impl Default for RateLimit {
}
}
/// Strategy for installing the package
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, ValueEnum)]
pub enum Strategy {
/// Attempt to download official pre-built artifacts using
/// information provided in `Cargo.toml`.
CrateMetaData,
/// Query third-party QuickInstall for the crates.
QuickInstall,
/// Build the crates from source using `cargo-build`.
Compile,
}
pub fn parse() -> Result<Args, BinstallError> {
// Filter extraneous arg when invoked by cargo
// `cargo run -- --help` gives ["target/debug/cargo-binstall", "--help"]