From 3a596c682f3c77a94c831d5993c2a62306b41496 Mon Sep 17 00:00:00 2001 From: messense Date: Fri, 18 Feb 2022 12:13:16 +0800 Subject: [PATCH] Update to clap 3.1 --- Cargo.lock | 63 +++++++++++++++++++++++++++-------------------------- Cargo.toml | 6 ++--- src/main.rs | 18 +++++++-------- src/zig.rs | 9 ++++---- 4 files changed, 49 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8af31d1b3..e183ae651 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -234,9 +234,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba2ae6de944143141f6155a473a6b02f66c7c3f9f47316f802f80204ebfe6e12" +checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" dependencies = [ "camino", "cargo-platform", @@ -265,9 +265,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.72" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" [[package]] name = "cfg-if" @@ -308,9 +308,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.0.14" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63edc3f163b3c71ec8aa23f9bd6070f77edbf3d1d198b164afa90ff00e4ec62" +checksum = "e5f1fea81f183005ced9e59cdb01737ef2423956dac5a6d731b06b2ecfaa3467" dependencies = [ "atty", "bitflags", @@ -326,18 +326,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "3.0.6" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678db4c39c013cc68b54d372bce2efc58e30a0337c497c9032fd196802df3bc3" +checksum = "23eec4dd324308f49d8bf86a2732078c34d57955fec1e1d865554fc37c15d420" dependencies = [ "clap", ] [[package]] name = "clap_complete_fig" -version = "3.0.2" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29cc003d824770d10072f4aa4a958e66d33d74a9cb7339595ac2a445d80d50a0" +checksum = "5c11f6f44afea4aee21bb57a5297879c88ac8dc97224fbbbe796edd60a098f0e" dependencies = [ "clap", "clap_complete", @@ -345,9 +345,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "3.0.14" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1132dc3944b31c20dd8b906b3a9f0a5d0243e092d59171414969657ac6aa85" +checksum = "5fd1122e63869df2cb309f449da1ad54a7c6dfeb7c7e6ccd8e0825d9eb93bb72" dependencies = [ "heck 0.4.0", "proc-macro-error", @@ -432,11 +432,12 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4600d695eb3f6ce1cd44e6e291adceb2cc3ab12f20a33777ecd0bf6eba34e06" +checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" dependencies = [ "generic-array", + "typenum", ] [[package]] @@ -486,9 +487,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cb780dce4f9a8f5c087362b3a4595936b2019e7c8b30f2c3e9a7e94e6ae9837" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" dependencies = [ "block-buffer 0.10.2", "crypto-common", @@ -918,9 +919,9 @@ dependencies = [ [[package]] name = "indoc" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5a75aeaaef0ce18b58056d306c27b07436fbb34b8816c53094b76dd81803136" +checksum = "e7906a9fababaeacb774f72410e497a1d18de916322e33797bb2cd29baa23c9e" dependencies = [ "unindent", ] @@ -980,9 +981,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.117" +version = "0.2.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c" +checksum = "06e509672465a0504304aa87f9f176f2b2b716ed8fb105ebe5c02dc6dce96a94" [[package]] name = "log" @@ -1050,7 +1051,7 @@ dependencies = [ "semver", "serde", "serde_json", - "sha2 0.10.1", + "sha2 0.10.2", "shlex", "tar", "target-lexicon", @@ -1076,9 +1077,9 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "mime_guess" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" dependencies = [ "mime", "unicase", @@ -1391,9 +1392,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ebace6889caf889b4d3f76becee12e90353f2b8c7d875534a71e5742f8f6f83" +checksum = "9dada8c9981fcf32929c3c0f0cd796a9284aca335565227ed88c83babb1d43dc" dependencies = [ "thiserror", "toml", @@ -1776,13 +1777,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99c3bd8169c58782adad9290a9af5939994036b76187f7b4f0e6de91dbbfc0ec" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" dependencies = [ "cfg-if 1.0.0", "cpufeatures", - "digest 0.10.2", + "digest 0.10.3", ] [[package]] @@ -2032,9 +2033,9 @@ checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "unindent" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" +checksum = "514672a55d7380da379785a4d70ca8386c8883ff7eaae877be4d2081cebe73d8" [[package]] name = "untrusted" @@ -2323,7 +2324,7 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4ca5e22593eb4212382d60d26350065bf2a02c34b85bc850474a74b589a3de9" dependencies = [ - "proc-macro-crate 1.1.0", + "proc-macro-crate 1.1.2", "proc-macro2", "quote", "syn", diff --git a/Cargo.toml b/Cargo.toml index e91114a02..5d691a9d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,9 +55,9 @@ console = "0.15.0" minijinja = "0.13.0" lddtree = "0.2.7" cc = "1.0.72" -clap = { version = "3.0.13", features = ["derive", "env", "wrap_help"] } -clap_complete = "3.0.6" -clap_complete_fig = "3.0.2" +clap = { version = "3.1.0", features = ["derive", "env", "wrap_help"] } +clap_complete = "3.1.0" +clap_complete_fig = "3.1.0" semver = "1.0.5" # upload configparser = { version = "3.0.0", optional = true } diff --git a/src/main.rs b/src/main.rs index 3722089a0..62641372b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ //! Run with --help for usage information use anyhow::{bail, Context, Result}; -use clap::{ArgEnum, IntoApp, Parser}; +use clap::{ArgEnum, IntoApp, Parser, Subcommand}; use clap_complete::Generator; use maturin::{ develop, init_project, new_project, write_dist_info, BridgeModel, BuildOptions, @@ -97,7 +97,7 @@ enum Opt { #[clap( short = 'E', long, - use_delimiter = true, + use_value_delimiter = true, multiple_values = false, multiple_occurrences = false )] @@ -158,7 +158,7 @@ enum Opt { #[clap(subcommand)] Pep517(Pep517Command), /// Generate shell completions - #[clap(name = "completions", setting = clap::AppSettings::Hidden)] + #[clap(name = "completions", hide = true)] Completions { #[clap(name = "SHELL", parse(try_from_str))] shell: Shell, @@ -171,8 +171,8 @@ enum Opt { /// Backend for the PEP 517 integration. Not for human consumption /// /// The commands are meant to be called from the python PEP 517 -#[derive(Debug, Parser)] -#[clap(name = "pep517", setting = clap::AppSettings::Hidden)] +#[derive(Debug, Subcommand)] +#[clap(name = "pep517", hide = true)] enum Pep517Command { /// The implementation of prepare_metadata_for_build_wheel #[clap(name = "write-dist-info")] @@ -427,12 +427,12 @@ fn run() -> Result<()> { upload_ui(&files, &publish)? } Opt::Completions { shell } => { - let mut app = Opt::into_app(); + let mut cmd = Opt::command(); match shell { Shell::Fig => { - app.set_bin_name(env!("CARGO_BIN_NAME")); + cmd.set_bin_name(env!("CARGO_BIN_NAME")); let fig = clap_complete_fig::Fig; - fig.generate(&app, &mut io::stdout()); + fig.generate(&cmd, &mut io::stdout()); } _ => { let shell = match shell { @@ -445,7 +445,7 @@ fn run() -> Result<()> { }; clap_complete::generate( shell, - &mut app, + &mut cmd, env!("CARGO_BIN_NAME"), &mut io::stdout(), ) diff --git a/src/zig.rs b/src/zig.rs index 61b0ab0d1..bb66dcd09 100644 --- a/src/zig.rs +++ b/src/zig.rs @@ -4,6 +4,7 @@ use crate::target::Arch; use crate::{BuildContext, PlatformTag}; use anyhow::{bail, Context, Result}; +use clap::Subcommand; use fs_err as fs; use std::env; #[cfg(target_family = "unix")] @@ -16,18 +17,18 @@ use std::process::{self, Command}; use std::str; /// Zig linker wrapper -#[derive(Debug, clap::Parser)] -#[clap(name = "zig", setting = clap::AppSettings::Hidden)] +#[derive(Debug, Subcommand)] +#[clap(name = "zig", hide = true)] pub enum Zig { /// `zig cc` wrapper - #[clap(name = "cc", setting = clap::AppSettings::TrailingVarArg)] + #[clap(name = "cc", trailing_var_arg = true)] Cc { /// `zig cc` arguments #[clap(takes_value = true, multiple_values = true)] args: Vec, }, /// `zig c++` wrapper - #[clap(name = "c++", setting = clap::AppSettings::TrailingVarArg)] + #[clap(name = "c++", trailing_var_arg = true)] Cxx { /// `zig c++` arguments #[clap(takes_value = true, multiple_values = true)]