From 81334b9e9239e178c3ef3308bcc4a661b466b79c Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Mon, 28 Nov 2022 16:10:34 +0100 Subject: [PATCH 1/3] Update clap to v4 --- Cargo.lock | 135 +++++++++++++++++++++++++++++++++++++++------- Cargo.toml | 4 +- src/main.rs | 2 +- src/output/mod.rs | 4 +- 4 files changed, 122 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02e281f..b65763b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,9 +25,9 @@ checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" [[package]] name = "async-tungstenite" -version = "0.17.2" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b71b31561643aa8e7df3effe284fa83ab1a840e52294c5f4bd7bfd8b2becbb" +checksum = "4b750efd83b7e716a015eed5ebb583cda83c52d9b24a8f0125e5c48c3313c9f8" dependencies = [ "futures-io", "futures-util", @@ -45,7 +45,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -124,27 +124,27 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "3.2.23" +version = "4.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +checksum = "0acbd8d28a0a60d7108d7ae850af6ba34cf2d1257fc646980e5f97ce14275966" dependencies = [ - "atty", "bitflags", "clap_derive", "clap_lex", - "indexmap", + "is-terminal", "once_cell", "strsim", "termcolor", - "textwrap", + "terminal_size", "unicase", + "unicode-width", ] [[package]] name = "clap_derive" -version = "3.2.18" +version = "4.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" dependencies = [ "heck", "proc-macro-error", @@ -155,9 +155,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" dependencies = [ "os_str_bytes", ] @@ -243,6 +243,27 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "eyre" version = "0.6.8" @@ -429,7 +450,7 @@ dependencies = [ [[package]] name = "ha-now-playing" -version = "0.4.6" +version = "0.4.7" dependencies = [ "anyhow", "async-tungstenite", @@ -468,6 +489,15 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + [[package]] name = "http" version = "0.2.8" @@ -574,12 +604,40 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "io-lifetimes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" + +[[package]] +name = "io-lifetimes" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +dependencies = [ + "libc", + "windows-sys 0.42.0", +] + [[package]] name = "ipnet" version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f88c5561171189e69df9d98bcf18fd5f9558300f7ea7b801eb8a0fd748bd8745" +[[package]] +name = "is-terminal" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae5bc6e2eb41c9def29a3e0f1306382807764b9b53112030eff57435667352d" +dependencies = [ + "hermit-abi 0.2.6", + "io-lifetimes 1.0.3", + "rustix 0.36.3", + "windows-sys 0.42.0", +] + [[package]] name = "itoa" version = "1.0.4" @@ -607,6 +665,18 @@ version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" +[[package]] +name = "linux-raw-sys" +version = "0.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" + +[[package]] +name = "linux-raw-sys" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f" + [[package]] name = "lock_api" version = "0.4.9" @@ -702,7 +772,7 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", ] @@ -1009,6 +1079,34 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +[[package]] +name = "rustix" +version = "0.35.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes 0.7.5", + "libc", + "linux-raw-sys 0.0.46", + "windows-sys 0.42.0", +] + +[[package]] +name = "rustix" +version = "0.36.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b1fbb4dfc4eb1d390c02df47760bb19a84bb80b301ecc947ab5406394d8223e" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes 1.0.3", + "libc", + "linux-raw-sys 0.1.3", + "windows-sys 0.42.0", +] + [[package]] name = "rustls" version = "0.20.7" @@ -1241,12 +1339,13 @@ dependencies = [ ] [[package]] -name = "textwrap" -version = "0.16.0" +name = "terminal_size" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" +checksum = "40ca90c434fd12083d1a6bdcbe9f92a14f96c8a1ba600ba451734ac334521f7a" dependencies = [ - "unicode-width", + "rustix 0.35.13", + "windows-sys 0.42.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 133c1ab..0965c7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,8 +8,8 @@ include = ["src/**/*"] [dependencies] anyhow = "1.0.56" -async-tungstenite = { version = "0.17.1", features = ["tokio-rustls-native-certs"] } -clap = { version = "3.1.6", features = ["cargo", "unicode", "derive", "env"] } +async-tungstenite = { version = "0.18.0", features = ["tokio-rustls-native-certs"] } +clap = { version = "4.0.27", features = ["cargo", "unicode", "derive", "env", "wrap_help"] } color-eyre = "0.6.1" futures = "0.3.21" reqwest = { version = "0.11.10", features = ["blocking", "json"] } diff --git a/src/main.rs b/src/main.rs index f72a524..7e4be76 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,7 +39,7 @@ struct Opts { /// Output format #[clap( - arg_enum, + value_enum, short, long, env = "HNP_OUTPUT_FORMAT", diff --git a/src/output/mod.rs b/src/output/mod.rs index 8224298..34169a8 100644 --- a/src/output/mod.rs +++ b/src/output/mod.rs @@ -1,11 +1,11 @@ use std::fmt::Display; -use clap::ArgEnum; +use clap::ValueEnum; pub(crate) mod i3blocks; pub(crate) mod waybar; -#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ArgEnum)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] pub(crate) enum OutputFormat { Waybar, I3Blocks, From e871964f303756f3fe1aadd21c1c2faa91a7e09e Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Mon, 28 Nov 2022 16:15:55 +0100 Subject: [PATCH 2/3] Removing short version for --host due to conflict with --help --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 7e4be76..11a07f2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,7 @@ mod output; #[clap(version, author, about)] struct Opts { /// Home Assistant host - #[clap(short, long, env = "HNP_HOST")] + #[clap(long, env = "HNP_HOST")] host: String, /// Media player entity ID From a6b2f9d8d749a8409b16f901e45ac0cfd0494f80 Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Mon, 28 Nov 2022 16:16:30 +0100 Subject: [PATCH 3/3] Custom pre-commit clippy hook to use the correct toolchain --- flake.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index e883ac6..32e986b 100644 --- a/flake.nix +++ b/flake.nix @@ -77,7 +77,17 @@ nixpkgs-fmt.enable = true; statix.enable = true; deadnix.enable = true; - clippy.enable = true; + rust-overlay-clippy = { + enable = true; + name = "rust-overlay clippy"; + entry = "${rustToolchain}/bin/cargo-clippy clippy"; + files = "\\.rs$"; + excludes = [ "^$" ]; + types = [ "file" ]; + types_or = [ ]; + language = "system"; + pass_filenames = false; + }; }; }; };