mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-14 14:46:37 +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>>,
|
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.
|
/// Override Cargo.toml package manifest path.
|
||||||
///
|
///
|
||||||
/// This skips searching crates.io for a manifest and uses the specified path directly, useful
|
/// 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,
|
desired_targets,
|
||||||
resolvers,
|
resolvers,
|
||||||
cargo_install_fallback,
|
cargo_install_fallback,
|
||||||
|
bins: args.bin,
|
||||||
|
|
||||||
temp_dir: temp_dir.path().to_owned(),
|
temp_dir: temp_dir.path().to_owned(),
|
||||||
install_path,
|
install_path,
|
||||||
|
|
|
@ -44,6 +44,7 @@ pub struct Options {
|
||||||
pub desired_targets: DesiredTargets,
|
pub desired_targets: DesiredTargets,
|
||||||
pub resolvers: Vec<Resolver>,
|
pub resolvers: Vec<Resolver>,
|
||||||
pub cargo_install_fallback: bool,
|
pub cargo_install_fallback: bool,
|
||||||
|
pub bins: Option<Vec<String>>,
|
||||||
|
|
||||||
pub temp_dir: PathBuf,
|
pub temp_dir: PathBuf,
|
||||||
pub install_path: PathBuf,
|
pub install_path: PathBuf,
|
||||||
|
|
|
@ -87,11 +87,16 @@ impl ResolutionFetch {
|
||||||
current_version: self.new_version,
|
current_version: self.new_version,
|
||||||
source: self.source,
|
source: self.source,
|
||||||
target: self.fetcher.target().to_compact_string(),
|
target: self.fetcher.target().to_compact_string(),
|
||||||
bins: self
|
bins: opts
|
||||||
.bin_files
|
.bins
|
||||||
.into_iter()
|
.as_ref()
|
||||||
.map(|bin| bin.base_name)
|
.map(|bins| bins.iter().cloned().map(Into::into).collect())
|
||||||
.collect(),
|
.unwrap_or_else(|| {
|
||||||
|
self.bin_files
|
||||||
|
.into_iter()
|
||||||
|
.map(|bin| bin.base_name)
|
||||||
|
.collect()
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
21
e2e-tests/specific-binaries.sh
Executable file
21
e2e-tests/specific-binaries.sh
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
unset CARGO_INSTALL_ROOT
|
||||||
|
|
||||||
|
CARGO_HOME=$(mktemp -d 2>/dev/null || mktemp -d -t 'cargo-home')
|
||||||
|
export CARGO_HOME
|
||||||
|
export PATH="$CARGO_HOME/bin:$PATH"
|
||||||
|
|
||||||
|
# Install a specific binary (e.g., ripgrep)
|
||||||
|
"./$1" binstall --no-confirm ripgrep --bin rg
|
||||||
|
|
||||||
|
# Verify that the binary was installed and is executable
|
||||||
|
if ! command -v rg >/dev/null 2>&1; then
|
||||||
|
echo "rg was not installed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run the binary to check it works
|
||||||
|
rg --version
|
3
justfile
3
justfile
|
@ -224,6 +224,7 @@ e2e-test-signing: (e2e-test "signing")
|
||||||
e2e-test-continue-on-failure: (e2e-test "continue-on-failure")
|
e2e-test-continue-on-failure: (e2e-test "continue-on-failure")
|
||||||
e2e-test-private-github-repo: (e2e-test "private-github-repo")
|
e2e-test-private-github-repo: (e2e-test "private-github-repo")
|
||||||
e2e-test-self-install: (e2e-test "self-install")
|
e2e-test-self-install: (e2e-test "self-install")
|
||||||
|
e2e-test-specific-binaries: (e2e-test "specific-binaries")
|
||||||
|
|
||||||
# WinTLS (Windows in CI) does not have TLS 1.3 support
|
# WinTLS (Windows in CI) does not have TLS 1.3 support
|
||||||
[windows]
|
[windows]
|
||||||
|
@ -232,7 +233,7 @@ e2e-test-tls: (e2e-test "tls" "1.2")
|
||||||
[macos]
|
[macos]
|
||||||
e2e-test-tls: (e2e-test "tls" "1.2") (e2e-test "tls" "1.3")
|
e2e-test-tls: (e2e-test "tls" "1.2") (e2e-test "tls" "1.3")
|
||||||
|
|
||||||
e2e-tests: e2e-test-live e2e-test-manifest-path e2e-test-git e2e-test-other-repos e2e-test-strategies e2e-test-version-syntax e2e-test-upgrade e2e-test-tls e2e-test-self-upgrade-no-symlink e2e-test-uninstall e2e-test-subcrate e2e-test-no-track e2e-test-registries e2e-test-signing e2e-test-continue-on-failure e2e-test-private-github-repo e2e-test-self-install
|
e2e-tests: e2e-test-live e2e-test-manifest-path e2e-test-git e2e-test-other-repos e2e-test-strategies e2e-test-version-syntax e2e-test-upgrade e2e-test-tls e2e-test-self-upgrade-no-symlink e2e-test-uninstall e2e-test-subcrate e2e-test-no-track e2e-test-registries e2e-test-signing e2e-test-continue-on-failure e2e-test-private-github-repo e2e-test-self-install e2e-test-specific-binaries
|
||||||
|
|
||||||
unit-tests: print-env
|
unit-tests: print-env
|
||||||
cargo test --no-run --target {{target}}
|
cargo test --no-run --target {{target}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue