diff --git a/Cargo.lock b/Cargo.lock index 8c985cad..11499219 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,7 +69,7 @@ dependencies = [ "bitflags", "cexpr", "clang-sys", - "clap", + "clap 2.34.0", "env_logger", "lazy_static", "lazycell", @@ -144,6 +144,7 @@ dependencies = [ "async-trait", "cargo_metadata", "cargo_toml", + "clap 3.1.18", "crates_io_api", "dirs", "env_logger", @@ -155,7 +156,6 @@ dependencies = [ "semver", "serde", "simplelog", - "structopt", "strum", "strum_macros", "tar", @@ -257,12 +257,51 @@ dependencies = [ "ansi_term", "atty", "bitflags", - "strsim", + "strsim 0.8.0", "textwrap 0.11.0", "unicode-width", "vec_map", ] +[[package]] +name = "clap" +version = "3.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b" +dependencies = [ + "atty", + "bitflags", + "clap_derive", + "clap_lex", + "indexmap", + "lazy_static", + "strsim 0.10.0", + "termcolor", + "textwrap 0.15.0", +] + +[[package]] +name = "clap_derive" +version = "3.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "cmake" version = "0.1.48" @@ -568,15 +607,6 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.4.0" @@ -922,6 +952,12 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" +[[package]] +name = "os_str_bytes" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" + [[package]] name = "owo-colors" version = "3.4.0" @@ -1261,28 +1297,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] -name = "structopt" -version = "0.3.26" +name = "strsim" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" -dependencies = [ - "clap", - "lazy_static", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" -dependencies = [ - "heck 0.3.3", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strum" @@ -1296,7 +1314,7 @@ version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef" dependencies = [ - "heck 0.4.0", + "heck", "proc-macro2", "quote", "rustversion", @@ -1595,12 +1613,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" - [[package]] name = "unicode-width" version = "0.1.9" diff --git a/Cargo.toml b/Cargo.toml index 1a4cfe4d..9f1f5f1f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ pkg-fmt = "zip" async-trait = "0.1.56" cargo_metadata = "0.14.2" cargo_toml = "0.11.4" +clap = { version = "3.1.18", features = ["derive"] } crates_io_api = { version = "0.8.0", default-features = false, features = ["rustls"] } dirs = "4.0.0" flate2 = { version = "1.0.24", features = ["zlib-ng"], default-features = false } @@ -31,7 +32,6 @@ reqwest = { version = "0.11.10", features = [ "rustls-tls" ], default-features = semver = "1.0.7" serde = { version = "1.0.136", features = [ "derive" ] } simplelog = "0.12.0" -structopt = "0.3.26" strum = "0.24.0" strum_macros = "0.24.0" tar = "0.4.38" diff --git a/src/main.rs b/src/main.rs index 3d04fd3d..f4ebbcc8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,10 +7,10 @@ use std::{ }; use cargo_toml::{Package, Product}; +use clap::Parser; use log::{debug, error, info, warn, LevelFilter}; use miette::{miette, IntoDiagnostic, Result, WrapErr}; use simplelog::{ColorChoice, ConfigBuilder, TermLogger, TerminalMode}; -use structopt::StructOpt; use tempfile::TempDir; use tokio::{process::Command, runtime::Runtime, task::JoinError}; @@ -20,64 +20,65 @@ use cargo_binstall::{ *, }; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] +#[clap(version, about = "Install a Rust binary... from binaries!")] struct Options { /// Package name or URL for installation /// This must be either a crates.io package name or github or gitlab url - #[structopt()] + #[clap(value_name = "crate")] name: String, /// Filter for package version to install, in Cargo.toml format. /// Use `=1.2.3` to install a specific version. - #[structopt(long, default_value = "*")] + #[clap(long, default_value = "*")] version: String, /// Override binary target, ignoring compiled version - #[structopt(long, default_value = TARGET)] + #[clap(help_heading = "OVERRIDES", long, default_value = TARGET)] target: String, /// Override install path for downloaded binary. /// Defaults to `$HOME/.cargo/bin` - #[structopt(long)] + #[clap(help_heading = "OVERRIDES", long)] install_path: Option, /// Disable symlinking / versioned updates - #[structopt(long)] + #[clap(long)] no_symlinks: bool, /// Dry run, fetch and show changes without installing binaries - #[structopt(long)] + #[clap(long)] dry_run: bool, /// Disable interactive mode / confirmation - #[structopt(long)] + #[clap(long)] no_confirm: bool, /// Do not cleanup temporary files on success - #[structopt(long)] + #[clap(long)] no_cleanup: bool, /// Override manifest source. /// This skips searching crates.io for a manifest and uses /// the specified path directly, useful for debugging and /// when adding `binstall` support. - #[structopt(long)] + #[clap(help_heading = "OVERRIDES", long)] manifest_path: Option, /// Utility log level - #[structopt(long, default_value = "info")] + #[clap(long, default_value = "info")] log_level: LevelFilter, /// Override Cargo.toml package manifest bin-dir. - #[structopt(long)] + #[clap(help_heading = "OVERRIDES", long)] bin_dir: Option, /// Override Cargo.toml package manifest pkg-fmt. - #[structopt(long)] + #[clap(help_heading = "OVERRIDES", long)] pkg_fmt: Option, /// Override Cargo.toml package manifest pkg-url. - #[structopt(long)] + #[clap(help_heading = "OVERRIDES", long)] pkg_url: Option, } @@ -140,7 +141,7 @@ async fn entry() -> Result<()> { } // Load options - let mut opts = Options::from_iter(args.iter()); + let mut opts = Options::parse_from(args.iter()); let cli_overrides = PkgOverride { pkg_url: opts.pkg_url.take(), pkg_fmt: opts.pkg_fmt.take(),