refactor: migrate to clap v4.0.0-rc.1

This commit is contained in:
Harsh Shandilya 2022-09-21 17:33:21 +05:30
parent 8914f9af60
commit 949cc55942
No known key found for this signature in database
5 changed files with 19 additions and 52 deletions

36
Cargo.lock generated
View File

@ -96,26 +96,24 @@ checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e"
[[package]] [[package]]
name = "clap" name = "clap"
version = "3.2.22" version = "4.0.0-rc.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" checksum = "9b01032b244c348ae40c5d99113438c95ee7343cd303bb361fc06dcb4c1d93e8"
dependencies = [ dependencies = [
"atty", "atty",
"bitflags", "bitflags",
"clap_derive", "clap_derive",
"clap_lex", "clap_lex",
"indexmap",
"once_cell", "once_cell",
"strsim", "strsim",
"termcolor", "termcolor",
"textwrap",
] ]
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "3.2.18" version = "4.0.0-rc.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" checksum = "51eef4d62724bf369e9ca7458cfde0c55263708b4552020058fba384864e8c23"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error", "proc-macro-error",
@ -126,9 +124,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_lex" name = "clap_lex"
version = "0.2.4" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [ dependencies = [
"os_str_bytes", "os_str_bytes",
] ]
@ -228,12 +226,6 @@ version = "0.26.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d"
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]] [[package]]
name = "hcctl" name = "hcctl"
version = "2.0.4" version = "2.0.4"
@ -299,16 +291,6 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
[[package]]
name = "indexmap"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.3" version = "1.0.3"
@ -687,12 +669,6 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "textwrap"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16"
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.32" version = "1.0.32"

View File

@ -14,7 +14,7 @@ include = ["src/**/*", "../LICENSE-*", "README.md"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
clap = { version = "3.2.22", features = [ "color", "deprecated", "derive" ] } clap = { version = "4.0.0-rc.1", features = [ "color", "deprecated", "derive" ] }
color-eyre = { version = "0.6.2", default-features = false } color-eyre = { version = "0.6.2", default-features = false }
comfy-table = "6.1.0" comfy-table = "6.1.0"
healthchecks = { path = "../healthchecks", version = "^3.1.2" } healthchecks = { path = "../healthchecks", version = "^3.1.2" }

View File

@ -1,4 +1,4 @@
use clap::{AppSettings, Parser}; use clap::Parser;
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct Settings { pub(crate) struct Settings {
@ -7,10 +7,9 @@ pub(crate) struct Settings {
} }
#[derive(Parser)] #[derive(Parser)]
#[clap(author, version, about)] #[command(author, version, about)]
#[clap(global_setting(AppSettings::DeriveDisplayOrder))]
pub(crate) struct Opts { pub(crate) struct Opts {
#[clap(subcommand)] #[command(subcommand)]
pub(crate) subcommand: SubCommand, pub(crate) subcommand: SubCommand,
} }

View File

@ -14,7 +14,7 @@ include = ["src/**/*", "../LICENSE-*", "README.md"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
clap = { version = "3.2.22", features = [ "color", "deprecated", "derive" ] } clap = { version = "4.0.0-rc.1", features = [ "color", "deprecated", "derive" ] }
color-eyre = { version = "0.6.2", default-features = false } color-eyre = { version = "0.6.2", default-features = false }
healthchecks = { path = "../healthchecks", version = "^3.1.2" } healthchecks = { path = "../healthchecks", version = "^3.1.2" }
subprocess = "0.2.9" subprocess = "0.2.9"

View File

@ -1,37 +1,29 @@
use clap::{AppSettings, Parser}; use clap::Parser;
/// This is useful to have a good-looking default in the clap generated help. /// This is useful to have a good-looking default in the clap generated help.
const FAKE_EMPTY_STRING: &str = "\"\""; const FAKE_EMPTY_STRING: &str = "\"\"";
#[derive(Parser)] #[derive(Parser)]
#[clap(author, version, about)] #[command(author, version, about)]
#[clap(global_setting(AppSettings::DeriveDisplayOrder))]
pub(crate) struct Opts { pub(crate) struct Opts {
/// command to execute and monitor /// command to execute and monitor
#[clap(short = 'X', long = "exec", action)] #[arg(short = 'X', long = "exec")]
pub(crate) command: Vec<String>, pub(crate) command: Vec<String>,
/// starts a timer before running the command /// starts a timer before running the command
#[clap(short = 't', long = "timer", action)] #[arg(short = 't', long = "timer")]
pub(crate) timer: bool, pub(crate) timer: bool,
/// saves the execution logs with the failure ping to allow debugging on healthchecks.io /// saves the execution logs with the failure ping to allow debugging on healthchecks.io
#[clap(short = 'l', long = "logs", action)] #[arg(short = 'l', long = "logs")]
pub(crate) save_logs: bool, pub(crate) save_logs: bool,
/// number of times to retry the command before logging a failure /// number of times to retry the command before logging a failure
#[clap( #[arg(short = 'r', long = "retries", default_value = "1", required = false)]
short = 'r',
long = "retries",
default_value = "1",
required = false,
action
)]
pub(crate) retry_count: u8, pub(crate) retry_count: u8,
/// user agent to be logged at healthchecks.io /// user agent to be logged at healthchecks.io
#[clap( #[arg(
short = 'u', short = 'u',
long = "user-agent", long = "user-agent",
required = false, required = false,
default_value = FAKE_EMPTY_STRING, default_value = FAKE_EMPTY_STRING
action,
)] )]
pub(crate) user_agent: String, pub(crate) user_agent: String,
} }