1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

chore: upgrade clap to v3 (#13266)

This commit is contained in:
Leo Kettmeir 2022-01-14 17:38:17 +01:00 committed by GitHub
parent 659bbd731c
commit e650165e80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 340 additions and 338 deletions

100
Cargo.lock generated
View file

@ -75,7 +75,7 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [
"getrandom 0.2.3",
"getrandom 0.2.4",
"once_cell",
"version_check",
]
@ -104,15 +104,6 @@ dependencies = [
"alloc-no-stdlib",
]
[[package]]
name = "ansi_term"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
@ -425,17 +416,36 @@ dependencies = [
[[package]]
name = "clap"
version = "2.33.3"
version = "3.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
checksum = "12e8611f9ae4e068fa3e56931fded356ff745e70987ff76924a6e0ab1c8ef2e3"
dependencies = [
"ansi_term 0.11.0",
"atty",
"bitflags",
"strsim 0.8.0",
"indexmap",
"os_str_bytes",
"strsim 0.10.0",
"termcolor",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]]
name = "clap_complete"
version = "3.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fff450c061c4de8162fd6fa0a7a73f70f10c211869a34897724823ed9ec0046"
dependencies = [
"clap",
]
[[package]]
name = "clap_complete_fig"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29cc003d824770d10072f4aa4a958e66d33d74a9cb7339595ac2a445d80d50a0"
dependencies = [
"clap",
"clap_complete",
]
[[package]]
@ -697,6 +707,8 @@ dependencies = [
"cache_control",
"chrono",
"clap",
"clap_complete",
"clap_complete_fig",
"data-url",
"deno_ast",
"deno_broadcast_channel",
@ -1648,9 +1660,9 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.3"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
dependencies = [
"cfg-if 1.0.0",
"libc",
@ -2544,6 +2556,15 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "os_str_bytes"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
dependencies = [
"memchr",
]
[[package]]
name = "output_vt100"
version = "0.1.2"
@ -2798,7 +2819,7 @@ version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cab0e7c02cf376875e9335e0ba1da535775beb5450d21e1dffca068818ed98b"
dependencies = [
"ansi_term 0.12.1",
"ansi_term",
"ctor",
"diff",
"output_vt100",
@ -2980,7 +3001,7 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [
"getrandom 0.2.3",
"getrandom 0.2.4",
]
[[package]]
@ -3544,9 +3565,9 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.7.0"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
[[package]]
name = "socket2"
@ -3667,18 +3688,18 @@ dependencies = [
"syn 1.0.65",
]
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "strsim"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "subtle"
version = "2.4.1"
@ -3756,9 +3777,9 @@ dependencies = [
[[package]]
name = "swc_ecma_ast"
version = "0.65.0"
version = "0.65.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accaa4affdc0e2f3693c9d3b325ad97e9d9534e01abe5564b9b85c5d1cacdcbb"
checksum = "279a4595711a9aaf02165398d5f317b89d718ab90d30b2c08f34abda6545aa3a"
dependencies = [
"is-macro",
"num-bigint",
@ -4026,9 +4047,9 @@ dependencies = [
[[package]]
name = "swc_ecmascript"
version = "0.108.1"
version = "0.108.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36c59346416fc6010a59c0fa10f19b8ba9a45bed7199005b7c452b68400fc345"
checksum = "ae93ca691a78c072b76045f70ffb9daf73e6e21530862c627c35a9a20bbd6d69"
dependencies = [
"swc_ecma_ast",
"swc_ecma_codegen",
@ -4227,12 +4248,9 @@ dependencies = [
[[package]]
name = "textwrap"
version = "0.11.0"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"unicode-width",
]
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
[[package]]
name = "thiserror"
@ -4719,7 +4737,7 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
dependencies = [
"getrandom 0.2.3",
"getrandom 0.2.4",
"serde",
]
@ -4742,12 +4760,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.4"

View file

@ -51,7 +51,9 @@ atty = "=0.2.14"
base64 = "=0.13.0"
cache_control = "=0.2.0"
chrono = "=0.4.19"
clap = "=2.33.3"
clap = "=3.0.7"
clap_complete = "=3.0.3"
clap_complete_fig = "=3.0.2"
data-url = "=0.1.1"
dissimilar = "=1.0.2"
dprint-plugin-json = "=0.14.0"

File diff suppressed because it is too large Load diff

View file

@ -26,7 +26,7 @@ impl FromStr for BarePort {
}
}
pub fn validator(host_and_port: String) -> Result<(), String> {
pub fn validator(host_and_port: &str) -> Result<(), String> {
if Url::parse(&format!("deno://{}", host_and_port)).is_ok()
|| host_and_port.parse::<IpAddr>().is_ok()
|| host_and_port.parse::<BarePort>().is_ok()
@ -53,9 +53,9 @@ pub fn parse(paths: Vec<String>) -> clap::Result<Vec<String>> {
out.push(format!("{}:{}", host, port.0));
}
} else {
return Err(clap::Error::with_description(
&format!("Bad host:port pair: {}", host_and_port),
return Err(clap::Error::raw(
clap::ErrorKind::InvalidValue,
format!("Bad host:port pair: {}", host_and_port),
));
}
}

View file

@ -1376,7 +1376,11 @@ fn unwrap_or_exit<T>(result: Result<T, AnyError>) -> T {
match result {
Ok(value) => value,
Err(error) => {
eprintln!("{}: {:?}", colors::red_bold("error"), error);
eprintln!(
"{}: {}",
colors::red_bold("error"),
format!("{:?}", error).trim_start_matches("error: ")
);
std::process::exit(1);
}
}
@ -1404,11 +1408,10 @@ pub fn main() {
let flags = match flags::flags_from_vec(args) {
Ok(flags) => flags,
Err(err @ clap::Error { .. })
if err.kind == clap::ErrorKind::HelpDisplayed
|| err.kind == clap::ErrorKind::VersionDisplayed =>
if err.kind == clap::ErrorKind::DisplayHelp
|| err.kind == clap::ErrorKind::DisplayVersion =>
{
err.write_to(&mut std::io::stdout()).unwrap();
std::io::stdout().write_all(b"\n").unwrap();
err.print().unwrap();
std::process::exit(0);
}
Err(err) => unwrap_or_exit(Err(AnyError::from(err))),