diff --git a/Cargo.lock b/Cargo.lock index ccc1c5e2be..a6de39cb98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,25 +42,62 @@ dependencies = [ ] [[package]] -name = "async-trait" -version = "0.1.73" +name = "anstream" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.37", + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", ] [[package]] -name = "atty" -version = "0.2.14" +name = "anstyle" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" + +[[package]] +name = "anstyle-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "async-trait" +version = "0.1.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -185,63 +222,70 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.25" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" dependencies = [ - "atty", - "bitflags 1.3.2", + "clap_builder", "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" +dependencies = [ + "anstream", + "anstyle", "clap_lex", - "indexmap 1.9.3", - "once_cell", "strsim", - "termcolor", "terminal_size", - "textwrap", ] [[package]] name = "clap_complete" -version = "3.2.5" +version = "4.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f7a2e0a962c45ce25afce14220bc24f9dade0a1787f185cecf96bfba7847cd8" +checksum = "e3ae8ba90b9d8b007efe66e55e48fb936272f5ca00349b5b0e89877520d35ea7" dependencies = [ "clap", ] [[package]] name = "clap_derive" -version = "3.2.25" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" +checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" dependencies = [ "heck", - "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" [[package]] name = "clap_mangen" -version = "0.1.11" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "105180c05a72388d5f5e4e4f6c79eecb92497bda749fa8f963a16647c5d5377f" +checksum = "b44f35c514163027542f7147797ff930523eea288e03642727348ef1a9666f6b" dependencies = [ "clap", "roff", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "config" version = "0.13.3" @@ -473,7 +517,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn", ] [[package]] @@ -663,15 +707,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.3" @@ -835,17 +870,6 @@ dependencies = [ "hashbrown 0.14.1", ] -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi 0.3.3", - "libc", - "windows-sys", -] - [[package]] name = "ipnet" version = "2.8.0" @@ -858,8 +882,8 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.3", - "rustix 0.38.14", + "hermit-abi", + "rustix", "windows-sys", ] @@ -907,7 +931,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.37", + "syn", ] [[package]] @@ -958,12 +982,6 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - [[package]] name = "linux-raw-sys" version = "0.4.7" @@ -1039,7 +1057,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi", "libc", ] @@ -1064,12 +1082,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" -[[package]] -name = "os_str_bytes" -version = "6.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" - [[package]] name = "parse-zoneinfo" version = "0.3.0" @@ -1122,7 +1134,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.37", + "syn", ] [[package]] @@ -1218,30 +1230,6 @@ dependencies = [ "log", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.67" @@ -1419,7 +1407,7 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn 2.0.37", + "syn", "walkdir", ] @@ -1439,20 +1427,6 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "rustix" -version = "0.37.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys", -] - [[package]] name = "rustix" version = "0.38.14" @@ -1462,7 +1436,7 @@ dependencies = [ "bitflags 2.4.0", "errno", "libc", - "linux-raw-sys 0.4.7", + "linux-raw-sys", "windows-sys", ] @@ -1555,7 +1529,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn", ] [[package]] @@ -1676,17 +1650,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.37" @@ -1731,23 +1694,14 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix 0.37.23", + "rustix", "windows-sys", ] -[[package]] -name = "textwrap" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" -dependencies = [ - "terminal_size", -] - [[package]] name = "thiserror" version = "1.0.49" @@ -1765,7 +1719,7 @@ checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn", ] [[package]] @@ -2049,6 +2003,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "vcpkg" version = "0.2.15" @@ -2107,7 +2067,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.37", + "syn", "wasm-bindgen-shared", ] @@ -2141,7 +2101,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/git-cliff/Cargo.toml b/git-cliff/Cargo.toml index 0cfd77ffc8..54dccbab88 100644 --- a/git-cliff/Cargo.toml +++ b/git-cliff/Cargo.toml @@ -29,24 +29,18 @@ default = ["update-informer"] glob.workspace = true regex.workspace = true log.workspace = true -pretty_env_logger = "0.5.0" dirs-next = "2.0.0" -clap_complete = "3.2.5" -clap_mangen = "0.1.11" +clap = { version = "4.4.6", features = ["derive", "env", "wrap_help", "cargo"] } +clap_complete = "4.4.3" +clap_mangen = "0.2.14" +pretty_env_logger = "0.5.0" shellexpand = "3.1.0" +update-informer = { version = "1.1.0", optional = true } [dependencies.git-cliff-core] version = "1.3.0" # managed by release.sh path = "../git-cliff-core" -[dependencies.clap] -version = "3.2.22" -features = ["derive", "env", "wrap_help"] - -[dependencies.update-informer] -version = "1.1.0" -optional = true - [dev-dependencies] pretty_assertions = "1.4.0" diff --git a/git-cliff/src/args.rs b/git-cliff/src/args.rs index cfc4246315..f534bffdf3 100644 --- a/git-cliff/src/args.rs +++ b/git-cliff/src/args.rs @@ -1,20 +1,20 @@ use clap::{ - AppSettings, - ArgEnum, + ArgAction, Parser, + ValueEnum, }; use git_cliff_core::DEFAULT_CONFIG; use glob::Pattern; use std::path::PathBuf; -#[derive(Debug, Clone, Copy, ArgEnum)] +#[derive(Debug, Clone, Copy, ValueEnum)] pub enum Strip { Header, Footer, All, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, ArgEnum)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)] pub enum Sort { Oldest, Newest, @@ -22,11 +22,10 @@ pub enum Sort { /// Command-line arguments to parse. #[derive(Debug, Parser)] -#[clap( +#[command( version, - author, + author = clap::crate_authors!("\n"), about, - global_setting = AppSettings::DeriveDisplayOrder, rename_all_env = "screaming-snake", help_template = "\ {before-help}{name} {version} @@ -37,61 +36,105 @@ pub enum Sort { {all-args}{after-help} ", override_usage = "git-cliff [FLAGS] [OPTIONS] [--] [RANGE]", - mut_arg("help", |arg| arg.help("Prints help information").help_heading("FLAGS")), - mut_arg("version", |arg| arg.help("Prints version information").help_heading("FLAGS")) + next_help_heading = Some("OPTIONS"), + disable_help_flag = true, + disable_version_flag = true, )] pub struct Opt { + #[arg( + short, + long, + action = ArgAction::Help, + global = true, + help = "Prints help information", + help_heading = "FLAGS" + )] + pub help: Option, + #[arg( + short = 'V', + long, + action = ArgAction::Version, + global = true, + help = "Prints version information", + help_heading = "FLAGS" + )] + pub version: Option, /// Increases the logging verbosity. - #[clap(short, long, parse(from_occurrences), alias = "debug", help_heading = Some("FLAGS"))] + #[arg(short, long, action = ArgAction::Count, alias = "debug", help_heading = Some("FLAGS"))] pub verbose: u8, /// Sets the configuration file. - #[clap(short, long, env = "GIT_CLIFF_CONFIG", value_name = "PATH", default_value = DEFAULT_CONFIG, value_parser = Opt::parse_dir)] + #[arg( + short, + long, + env = "GIT_CLIFF_CONFIG", + value_name = "PATH", + default_value = DEFAULT_CONFIG, + value_parser = Opt::parse_dir + )] pub config: PathBuf, /// Sets the working directory. - #[clap(short, long, env = "GIT_CLIFF_WORKDIR", value_name = "PATH", value_parser = Opt::parse_dir)] + #[arg( + short, + long, + env = "GIT_CLIFF_WORKDIR", + value_name = "PATH", + value_parser = Opt::parse_dir + )] pub workdir: Option, /// Sets the git repository. - #[clap( + #[arg( short, long, env = "GIT_CLIFF_REPOSITORY", value_name = "PATH", - multiple_values = true, - value_parser = Opt::parse_dir, + num_args(1..), + value_parser = Opt::parse_dir )] pub repository: Option>, /// Sets the path to include related commits. - #[clap( + #[arg( long, env = "GIT_CLIFF_INCLUDE_PATH", value_name = "PATTERN", - multiple_values = true + num_args(1..) )] pub include_path: Option>, /// Sets the path to exclude related commits. - #[clap( + #[arg( long, env = "GIT_CLIFF_EXCLUDE_PATH", value_name = "PATTERN", - multiple_values = true + num_args(1..) )] pub exclude_path: Option>, /// Sets custom commit messages to include in the changelog. - #[clap( + #[arg( long, env = "GIT_CLIFF_WITH_COMMIT", value_name = "MSG", - multiple_values = true + num_args(1..) )] pub with_commit: Option>, /// Prepends entries to the given changelog file. - #[clap(short, long, env = "GIT_CLIFF_PREPEND", value_name = "PATH", value_parser = Opt::parse_dir)] + #[arg( + short, + long, + env = "GIT_CLIFF_PREPEND", + value_name = "PATH", + value_parser = Opt::parse_dir + )] pub prepend: Option, /// Writes output to the given file. - #[clap(short, long, env = "GIT_CLIFF_OUTPUT", value_name = "PATH", value_parser = Opt::parse_dir)] + #[arg( + short, + long, + env = "GIT_CLIFF_OUTPUT", + value_name = "PATH", + value_parser = Opt::parse_dir + )] pub output: Option, /// Sets the tag for the latest version. - #[clap( + #[arg( short, long, env = "GIT_CLIFF_TAG", @@ -100,7 +143,7 @@ pub struct Opt { )] pub tag: Option, /// Sets the template for the changelog body. - #[clap( + #[arg( short, long, env = "GIT_CLIFF_TEMPLATE", @@ -109,35 +152,35 @@ pub struct Opt { )] pub body: Option, /// Writes the default configuration file to cliff.toml - #[clap(short, long, help_heading = Some("FLAGS"))] + #[arg(short, long, help_heading = Some("FLAGS"))] pub init: bool, /// Processes the commits starting from the latest tag. - #[clap(short, long, help_heading = Some("FLAGS"))] + #[arg(short, long, help_heading = Some("FLAGS"))] pub latest: bool, /// Processes the commits that belong to the current tag. - #[clap(long, help_heading = Some("FLAGS"))] + #[arg(long, help_heading = Some("FLAGS"))] pub current: bool, /// Processes the commits that do not belong to a tag. - #[clap(short, long, help_heading = Some("FLAGS"))] + #[arg(short, long, help_heading = Some("FLAGS"))] pub unreleased: bool, /// Sorts the tags topologically. - #[clap(long, help_heading = Some("FLAGS"))] + #[arg(long, help_heading = Some("FLAGS"))] pub topo_order: bool, /// Prints changelog context as JSON. - #[clap(long, help_heading = Some("FLAGS"))] + #[arg(long, help_heading = Some("FLAGS"))] pub context: bool, /// Strips the given parts from the changelog. - #[clap(short, long, value_name = "PART", arg_enum)] + #[arg(short, long, value_name = "PART", value_enum)] pub strip: Option, /// Sets sorting of the commits inside sections. - #[clap( + #[arg( long, - arg_enum, + value_enum, default_value_t = Sort::Oldest )] pub sort: Sort, /// Sets the commit range to process. - #[clap(value_name = "RANGE", help_heading = Some("ARGS"))] + #[arg(value_name = "RANGE", help_heading = Some("ARGS"))] pub range: Option, } diff --git a/git-cliff/src/bin/completions.rs b/git-cliff/src/bin/completions.rs index 5a6374d68b..ee0c5fa01c 100644 --- a/git-cliff/src/bin/completions.rs +++ b/git-cliff/src/bin/completions.rs @@ -1,6 +1,6 @@ use clap::{ - ArgEnum, CommandFactory, + ValueEnum, }; use clap_complete::Shell; use git_cliff::args::Opt; diff --git a/git-cliff/src/lib.rs b/git-cliff/src/lib.rs index b70d9ca523..cf94f57405 100644 --- a/git-cliff/src/lib.rs +++ b/git-cliff/src/lib.rs @@ -9,7 +9,7 @@ use args::{ Sort, Strip, }; -use clap::ArgEnum; +use clap::ValueEnum; use git_cliff_core::changelog::Changelog; use git_cliff_core::commit::Commit; use git_cliff_core::config::Config;