diff --git a/Cargo.lock b/Cargo.lock index ffbb851..fc39bd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,15 +11,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi", -] - [[package]] name = "anyhow" version = "1.0.47" @@ -87,17 +78,41 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "2.33.3" +version = "3.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "23b71c3ce99b7611011217b366d923f1d0a7e07a92bb2dbf1e84508c673ca3bd" dependencies = [ - "ansi_term", "atty", "bitflags", + "clap_derive", + "clap_lex", + "indexmap", + "once_cell", "strsim", + "termcolor", "textwrap", - "unicode-width", - "vec_map", +] + +[[package]] +name = "clap_derive" +version = "3.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", ] [[package]] @@ -324,12 +339,9 @@ checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" [[package]] name = "heck" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" [[package]] name = "hermit-abi" @@ -345,6 +357,7 @@ name = "hopper" version = "0.1.0" dependencies = [ "anyhow", + "clap", "confy", "console", "dialoguer", @@ -355,7 +368,6 @@ dependencies = [ "reqwest", "serde", "serde_json", - "structopt", "tokio", ] @@ -614,9 +626,9 @@ checksum = "17b02fc0ff9a9e4b35b3342880f48e896ebf69f2967921fe8646bf5b7125956a" [[package]] name = "once_cell" -version = "1.8.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" [[package]] name = "openssl" @@ -651,6 +663,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "os_str_bytes" +version = "6.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" + [[package]] name = "parking_lot" version = "0.11.2" @@ -989,33 +1007,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "structopt" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c" -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", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" @@ -1063,12 +1057,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.11.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "tinyvec" @@ -1196,12 +1187,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" - [[package]] name = "unicode-width" version = "0.1.9" @@ -1232,12 +1217,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.3" diff --git a/Cargo.toml b/Cargo.toml index 6e67e88..be435aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,5 +16,5 @@ log = "0.4.14" reqwest = { version = "0.11", features = ["json", "stream"] } serde = { version = "1", features = ["derive"] } serde_json = "1" -structopt = "0.3" +clap = { version = "3.2.20", features = ["derive"] } tokio = { version = "1", features = ["full"] } diff --git a/src/config.rs b/src/config.rs index 44aa5a2..f6addbe 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,51 +1,48 @@ +use clap::{Parser, Subcommand}; use serde::{Deserialize, Serialize}; use std::path::PathBuf; -use structopt::StructOpt; // TODO parameter to restrict target Minecraft version -#[derive(StructOpt, Clone, Debug)] +#[derive(clap::Args, Clone, Debug)] pub struct SearchArgs { pub package_name: String, /// Restricts the target Minecraft version - #[structopt(short, long)] + #[clap(short, long)] pub version: Option>, } // TODO use ColoredHelp by default? -#[derive(StructOpt, Clone, Debug)] +#[derive(Subcommand, Clone, Debug)] pub enum Command { /// Adds a mod to the current instance - #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] Add(SearchArgs), /// Removes a mod - #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] - Remove { package_name: String }, - #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] + Remove { + package_name: String, + }, Get(SearchArgs), - #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] Update, - #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] Clean, } // TODO move main body argument fields to substruct for ease of moving? -#[derive(StructOpt, Clone, Debug)] -#[structopt(name = "hopper", setting = structopt::clap::AppSettings::ColoredHelp)] +#[derive(Parser, Clone, Debug)] +#[clap(name = "hopper")] pub struct Args { /// Path to configuration file - #[structopt(short, long, parse(from_os_str))] + #[clap(short, long, value_parser)] pub config: Option, /// Path to mod lockfile - #[structopt(short, long, parse(from_os_str))] + #[clap(short, long, value_parser)] pub lockfile: Option, /// Auto-accept confirmation dialogues - #[structopt(short = "y", long = "yes")] + #[clap(short = 'y', long = "yes")] pub auto_accept: bool, - #[structopt(subcommand)] + #[clap(subcommand)] pub command: Command, } diff --git a/src/main.rs b/src/main.rs index b50fc8b..ec7553e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,9 @@ -use structopt::StructOpt; - mod api; mod client; mod config; use api::*; +use clap::Parser; use client::*; use config::*; @@ -112,7 +111,7 @@ async fn cmd_get(ctx: &AppContext, search_args: SearchArgs) -> anyhow::Result<() #[tokio::main] async fn main() -> anyhow::Result<()> { env_logger::init(); - let args = Args::from_args(); + let args = Args::parse(); let config = args.load_config()?; let ctx = AppContext { args, config }; match ctx.args.to_owned().command {