From 390efd39b3eb891a7501d98706db47f859410b85 Mon Sep 17 00:00:00 2001 From: Bert JW Regeer Date: Sun, 2 Oct 2022 14:18:24 -0600 Subject: [PATCH] Upgrade to clap 4.x --- Cargo.lock | 44 +++++++------------------------------------- Cargo.toml | 4 ++-- src/cli.rs | 12 ++++++------ 3 files changed, 15 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 41565e6..9765442 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,15 +19,9 @@ dependencies = [ "winapi", ] -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - [[package]] name = "barnacle" -version = "0.1.1" +version = "0.2.0" dependencies = [ "anyhow", "clap", @@ -43,26 +37,24 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "clap" -version = "3.2.22" +version = "4.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" +checksum = "5840cd9093aabeabf7fd932754c435b7674520fc3ddc935c397837050f0f1e4b" dependencies = [ "atty", "bitflags", "clap_derive", "clap_lex", - "indexmap", "once_cell", "strsim", "termcolor", - "textwrap", ] [[package]] name = "clap_derive" -version = "3.2.18" +version = "4.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +checksum = "92289ffc6fb4a85d85c246ddb874c05a87a2e540fb6ad52f7ca07c8c1e1840b1" dependencies = [ "heck", "proc-macro-error", @@ -73,19 +65,13 @@ 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", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "heck" version = "0.4.0" @@ -101,16 +87,6 @@ dependencies = [ "libc", ] -[[package]] -name = "indexmap" -version = "1.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" -dependencies = [ - "autocfg", - "hashbrown", -] - [[package]] name = "itoa" version = "1.0.3" @@ -257,12 +233,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "textwrap" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" - [[package]] name = "thiserror" version = "1.0.37" diff --git a/Cargo.toml b/Cargo.toml index c5e9683..d9fa4a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "barnacle" -version = "0.1.1" +version = "0.2.0" edition = "2021" authors = ["Bert JW Regeer "] license = "ISC" @@ -12,6 +12,6 @@ readme = "README.md" [dependencies] anyhow = "1.0" -clap = { version = "3.1", features = ["derive", "env"] } +clap = { version = "^4.0", features = ["derive", "env"] } minijinja = { version = "^0.23", features = ["source", "json", "urlencode"] } thiserror = "1.0" diff --git a/src/cli.rs b/src/cli.rs index 29f7a6f..7f9a309 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -2,21 +2,21 @@ use clap::Parser; use std::path::PathBuf; #[derive(Parser, Debug)] -#[clap(author, version, about)] +#[command(author, version, about)] pub struct Cli { /// Jinja2 template to render - #[clap(parse(from_os_str))] + #[arg()] pub template: PathBuf, /// The location to place the rendered file - #[clap(parse(from_os_str))] + #[arg()] pub output: PathBuf, /// The command + arguments to execute once template is rendered - #[clap(required(true))] + #[arg(required(true))] pub command: Vec, /// Turn debugging information on - #[clap(short, long, parse(from_occurrences))] - pub verbose: usize, + #[arg(short, long, action = clap::ArgAction::Count)] + pub verbose: u8, }