git.delta.rocks / jrsonnet / refs/commits / bb34d421e2a0

difftreelog

refactor replace clap with structopt

Yaroslav Bolyukin2021-09-30parent: #b47cfbf.patch.diff
in: trunk

6 files changed

modifiedCargo.lockdiffbeforeafterboth
327 "atty",327 "atty",
328 "bitflags",328 "bitflags",
329 "strsim 0.8.0",329 "strsim 0.8.0",
330 "textwrap 0.11.0",330 "textwrap",
331 "unicode-width",331 "unicode-width",
332 "vec_map",332 "vec_map",
333]333]
334
335[[package]]
336name = "clap"
337version = "3.0.0-beta.2"
338source = "registry+https://github.com/rust-lang/crates.io-index"
339checksum = "4bd1061998a501ee7d4b6d449020df3266ca3124b941ec56cf2005c3779ca142"
340dependencies = [
341 "atty",
342 "bitflags",
343 "clap_derive",
344 "indexmap",
345 "lazy_static",
346 "os_str_bytes",
347 "strsim 0.10.0",
348 "termcolor",
349 "textwrap 0.12.1",
350 "unicode-width",
351 "vec_map",
352]
353
354[[package]]
355name = "clap_derive"
356version = "3.0.0-beta.2"
357source = "registry+https://github.com/rust-lang/crates.io-index"
358checksum = "370f715b81112975b1b69db93e0b56ea4cd4e5002ac43b2da8474106a54096a1"
359dependencies = [
360 "heck",
361 "proc-macro-error",
362 "proc-macro2",
363 "quote",
364 "syn",
365]
366334
367[[package]]335[[package]]
368name = "cookie-factory"336name = "cookie-factory"
478 "anyhow",446 "anyhow",
479 "base64",447 "base64",
480 "chrono",448 "chrono",
481 "clap 3.0.0-beta.2",
482 "env_logger",449 "env_logger",
483 "hostname",450 "hostname",
484 "log",451 "log",
487 "peg",454 "peg",
488 "serde",455 "serde",
489 "serde_json",456 "serde_json",
457 "structopt",
490 "tempfile",458 "tempfile",
491 "time 0.3.2",459 "time 0.3.2",
492 "z85",460 "z85",
596 "wasi 0.10.2+wasi-snapshot-preview1",564 "wasi 0.10.2+wasi-snapshot-preview1",
597]565]
598
599[[package]]
600name = "hashbrown"
601version = "0.9.1"
602source = "registry+https://github.com/rust-lang/crates.io-index"
603checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
604566
605[[package]]567[[package]]
606name = "heck"568name = "heck"
725 "syn",687 "syn",
726]688]
727
728[[package]]
729name = "indexmap"
730version = "1.6.0"
731source = "registry+https://github.com/rust-lang/crates.io-index"
732checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2"
733dependencies = [
734 "autocfg 1.0.1",
735 "hashbrown",
736]
737689
738[[package]]690[[package]]
739name = "instant"691name = "instant"
954source = "registry+https://github.com/rust-lang/crates.io-index"906source = "registry+https://github.com/rust-lang/crates.io-index"
955checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"907checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
956
957[[package]]
958name = "os_str_bytes"
959version = "2.3.2"
960source = "registry+https://github.com/rust-lang/crates.io-index"
961checksum = "2ac6fe3538f701e339953a3ebbe4f39941aababa8a3f6964635b24ab526daeac"
962908
963[[package]]909[[package]]
964name = "ouroboros"910name = "ouroboros"
11541100
1155[[package]]1101[[package]]
1156name = "rand"1102name = "rand"
1157version = "0.8.3"1103version = "0.8.4"
1158source = "registry+https://github.com/rust-lang/crates.io-index"1104source = "registry+https://github.com/rust-lang/crates.io-index"
1159checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"1105checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
1160dependencies = [1106dependencies = [
1161 "libc",1107 "libc",
1162 "rand_chacha 0.3.0",1108 "rand_chacha 0.3.0",
1458source = "registry+https://github.com/rust-lang/crates.io-index"1404source = "registry+https://github.com/rust-lang/crates.io-index"
1459checksum = "bf9d950ef167e25e0bdb073cf1d68e9ad2795ac826f2f3f59647817cf23c0bfa"1405checksum = "bf9d950ef167e25e0bdb073cf1d68e9ad2795ac826f2f3f59647817cf23c0bfa"
1460dependencies = [1406dependencies = [
1461 "clap 2.33.3",1407 "clap",
1462 "lazy_static",1408 "lazy_static",
1463 "structopt-derive",1409 "structopt-derive",
1464]1410]
1519dependencies = [1465dependencies = [
1520 "cfg-if",1466 "cfg-if",
1521 "libc",1467 "libc",
1522 "rand 0.8.3",1468 "rand 0.8.4",
1523 "redox_syscall",1469 "redox_syscall",
1524 "remove_dir_all",1470 "remove_dir_all",
1525 "winapi",1471 "winapi",
1543 "unicode-width",1489 "unicode-width",
1544]1490]
1545
1546[[package]]
1547name = "textwrap"
1548version = "0.12.1"
1549source = "registry+https://github.com/rust-lang/crates.io-index"
1550checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789"
1551dependencies = [
1552 "unicode-width",
1553]
15541491
1555[[package]]1492[[package]]
1556name = "thiserror"1493name = "thiserror"
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,7 +7,6 @@
 
 [dependencies]
 anyhow = "1.0"
-clap = { version = "3.0.0-beta.2", features = ["derive", "suggestions", "color"] }
 log = "0.4.14"
 env_logger = "0.9.0"
 serde = { version = "1.0", features = ["derive"] }
@@ -23,6 +22,7 @@
 base64 = "0.13.0"
 chrono = { version = "0.4.19", features = ["serde"] }
 z85 = "3.0.3"
+structopt = "0.3.23"
 
 [workspace]
 members = ["crates/nixlike", "cmds/install-secrets"]
modifiedsrc/cmds/build_systems.rsdiffbeforeafterboth
--- a/src/cmds/build_systems.rs
+++ b/src/cmds/build_systems.rs
@@ -2,28 +2,27 @@
 
 use crate::{command::CommandExt, host::Config, nix::SYSTEMS_ATTRIBUTE};
 use anyhow::Result;
-use clap::Clap;
 use log::info;
+use structopt::StructOpt;
 
-#[derive(Clap)]
-#[clap(group = clap::ArgGroup::new("target"))]
+#[derive(StructOpt)]
 pub struct BuildSystems {
 	/// --builders arg for nix
-	#[clap(long)]
+	#[structopt(long)]
 	builders: Option<String>,
 	/// Jobs to run locally
-	#[clap(long)]
+	#[structopt(long)]
 	jobs: Option<usize>,
 	/// Do not continue on error
-	#[clap(long)]
+	#[structopt(long)]
 	fail_fast: bool,
-	#[clap(long)]
+	#[structopt(long)]
 	privileged_build: bool,
-	#[clap(subcommand)]
+	#[structopt(subcommand)]
 	subcommand: Option<Subcommand>,
 }
 
-#[derive(Clap)]
+#[derive(StructOpt)]
 enum Subcommand {
 	/// Switch to built system until reboot
 	Test,
modifiedsrc/cmds/secrets/mod.rsdiffbeforeafterboth
--- a/src/cmds/secrets/mod.rs
+++ b/src/cmds/secrets/mod.rs
@@ -1,9 +1,9 @@
 use crate::{fleetdata::FleetSecret, host::Config};
 use anyhow::{bail, Result};
-use clap::Clap;
 use std::io::{self, Cursor, Read};
+use structopt::StructOpt;
 
-#[derive(Clap)]
+#[derive(StructOpt)]
 pub enum Secrets {
 	/// Force load keys for all defined hosts
 	ForceKeys,
@@ -14,9 +14,9 @@
 		/// Secret owners
 		machines: Vec<String>,
 		/// Override secret if already present
-		#[clap(long)]
+		#[structopt(long)]
 		force: bool,
-		#[clap(long)]
+		#[structopt(long)]
 		public: Option<String>,
 	},
 }
modifiedsrc/host.rsdiffbeforeafterboth
--- a/src/host.rs
+++ b/src/host.rs
@@ -9,7 +9,8 @@
 };
 
 use anyhow::Result;
-use clap::Clap;
+use structopt::clap::ArgGroup;
+use structopt::StructOpt;
 
 use crate::{command::CommandExt, fleetdata::FleetData};
 
@@ -102,19 +103,19 @@
 	}
 }
 
-#[derive(Clap, Clone)]
-#[clap(group = clap::ArgGroup::new("target_hosts"))]
+#[derive(StructOpt, Clone)]
+#[structopt(group = ArgGroup::with_name("target_hosts"))]
 pub struct FleetOpts {
 	/// All hosts except those would be skipped
-	#[clap(long, number_of_values = 1, group = "target_hosts")]
+	#[structopt(long, number_of_values = 1, group = "target_hosts")]
 	only: Vec<String>,
 
 	/// Hosts to skip
-	#[clap(long, number_of_values = 1, group = "target_hosts")]
+	#[structopt(long, number_of_values = 1, group = "target_hosts")]
 	skip: Vec<String>,
 
 	/// Host, which should be threaten as current machine
-	#[clap(long)]
+	#[structopt(long)]
 	pub localhost: Option<String>,
 }
 
modifiedsrc/main.rsdiffbeforeafterboth
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,13 +8,13 @@
 mod fleetdata;
 
 use anyhow::Result;
-use clap::Clap;
+use structopt::StructOpt;
 
 use cmds::{build_systems::BuildSystems, secrets::Secrets};
 use host::{Config, FleetOpts};
 
-#[derive(Clap)]
-#[clap(version = "1.0", author = "CertainLach <iam@lach.pw>")]
+#[derive(StructOpt)]
+#[structopt(version = "1.0", author = "CertainLach <iam@lach.pw>")]
 enum Opts {
 	/// Prepare systems for deployments
 	BuildSystems(BuildSystems),
@@ -22,11 +22,11 @@
 	Secrets(Secrets),
 }
 
-#[derive(Clap)]
+#[derive(StructOpt)]
 struct RootOpts {
-	#[clap(flatten)]
+	#[structopt(flatten)]
 	fleet_opts: FleetOpts,
-	#[clap(subcommand)]
+	#[structopt(subcommand)]
 	command: Opts,
 }
 
@@ -42,7 +42,7 @@
 	env_logger::Builder::new()
 		.filter_level(log::LevelFilter::Info)
 		.init();
-	let opts = RootOpts::parse();
+	let opts = RootOpts::from_args();
 	let config = opts.fleet_opts.build()?;
 
 	match run_command(&config, opts.command) {