mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-16 07:36:38 +00:00
Add a --bin argument to mirror cargo install --bin.
This commit is contained in:
parent
ea65a39d2d
commit
75b3ef44fe
6 changed files with 49 additions and 6 deletions
|
@ -93,6 +93,20 @@ pub struct Args {
|
|||
)]
|
||||
pub(crate) targets: Option<Vec<String>>,
|
||||
|
||||
/// Install only the specified binaries.
|
||||
///
|
||||
/// This mirrors the equivalent argument in `cargo install --bin`.
|
||||
///
|
||||
/// If omitted, all binaries are installed.
|
||||
#[clap(
|
||||
help_heading = "Package selection",
|
||||
long,
|
||||
value_name = "BINARY",
|
||||
num_args = 1..,
|
||||
action = clap::ArgAction::Append
|
||||
)]
|
||||
pub(crate) bin: Option<Vec<String>>,
|
||||
|
||||
/// Override Cargo.toml package manifest path.
|
||||
///
|
||||
/// This skips searching crates.io for a manifest and uses the specified path directly, useful
|
||||
|
|
|
@ -157,6 +157,7 @@ pub fn install_crates(
|
|||
desired_targets,
|
||||
resolvers,
|
||||
cargo_install_fallback,
|
||||
bins: args.bin,
|
||||
|
||||
temp_dir: temp_dir.path().to_owned(),
|
||||
install_path,
|
||||
|
|
|
@ -44,6 +44,7 @@ pub struct Options {
|
|||
pub desired_targets: DesiredTargets,
|
||||
pub resolvers: Vec<Resolver>,
|
||||
pub cargo_install_fallback: bool,
|
||||
pub bins: Option<Vec<String>>,
|
||||
|
||||
pub temp_dir: PathBuf,
|
||||
pub install_path: PathBuf,
|
||||
|
|
|
@ -87,11 +87,16 @@ impl ResolutionFetch {
|
|||
current_version: self.new_version,
|
||||
source: self.source,
|
||||
target: self.fetcher.target().to_compact_string(),
|
||||
bins: self
|
||||
.bin_files
|
||||
.into_iter()
|
||||
.map(|bin| bin.base_name)
|
||||
.collect(),
|
||||
bins: opts
|
||||
.bins
|
||||
.as_ref()
|
||||
.map(|bins| bins.iter().cloned().map(Into::into).collect())
|
||||
.unwrap_or_else(|| {
|
||||
self.bin_files
|
||||
.into_iter()
|
||||
.map(|bin| bin.base_name)
|
||||
.collect()
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue