From 4796db333d2830f69a71f249016ed5e5194f3593 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Fri, 3 Jan 2025 21:10:16 -0800 Subject: [PATCH] Migrate to clap4 Closes #775 --- Cargo.lock | 192 ++++++++++++++++++++++++++----------------------- Cargo.toml | 2 +- src/options.rs | 16 +---- 3 files changed, 106 insertions(+), 104 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 30b92e34fe..9181cd453e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,6 +29,55 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "anstream" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "assert_cmd" version = "2.0.8" @@ -43,17 +92,6 @@ dependencies = [ "wait-timeout", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -106,29 +144,37 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "3.2.25" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" dependencies = [ - "atty", - "bitflags 1.3.2", + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" +dependencies = [ + "anstream", + "anstyle", "clap_lex", - "indexmap 1.9.3", - "once_cell", - "strsim", - "termcolor", + "strsim 0.11.1", "terminal_size", - "textwrap", ] [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" + +[[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "const_format" @@ -223,7 +269,7 @@ dependencies = [ "const_format", "crossterm", "glob", - "hashbrown 0.14.3", + "hashbrown", "humansize", "ignore", "itertools 0.11.0", @@ -245,7 +291,7 @@ dependencies = [ "serde_json", "smallvec", "streaming-iterator", - "strsim", + "strsim 0.10.0", "strum", "tree-sitter", "tree-sitter-bash", @@ -361,12 +407,6 @@ dependencies = [ "regex-syntax", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "hashbrown" version = "0.14.3" @@ -383,15 +423,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[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.9" @@ -440,16 +471,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - [[package]] name = "indexmap" version = "2.2.6" @@ -457,18 +478,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", -] - -[[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.9", - "libc", - "windows-sys 0.48.0", + "hashbrown", ] [[package]] @@ -477,11 +487,17 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -541,9 +557,9 @@ checksum = "7b25f5068853805faa3c19f44d0c401446e4eb3f47cc808fa331eec30f0ba35c" [[package]] name = "linux-raw-sys" -version = "0.3.8" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" @@ -625,12 +641,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "os_str_bytes" -version = "6.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" - [[package]] name = "owo-colors" version = "3.5.0" @@ -667,7 +677,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.2.6", + "indexmap", ] [[package]] @@ -810,16 +820,15 @@ checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustix" -version = "0.37.27" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "errno", - "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -934,6 +943,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "strum" version = "0.26.3" @@ -978,9 +993,9 @@ 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", "windows-sys 0.48.0", @@ -992,15 +1007,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" -[[package]] -name = "textwrap" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" -dependencies = [ - "terminal_size", -] - [[package]] name = "thread_local" version = "1.1.8" @@ -1308,6 +1314,12 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index a0658c4ab4..d15808e3e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ pkg-fmt = "zip" [dependencies] regex = "1.10.4" -clap = { version = "3.2.25", features = ["cargo", "env", "wrap_help"] } +clap = { version = "4.0.0", features = ["cargo", "env", "wrap_help"] } itertools = "0.11.0" typed-arena = "2.0.2" rustc-hash = "2.0.0" diff --git a/src/options.rs b/src/options.rs index adec069cb0..73c22591aa 100644 --- a/src/options.rs +++ b/src/options.rs @@ -91,7 +91,7 @@ impl Default for DiffOptions { } } -fn app() -> clap::Command<'static> { +fn app() -> clap::Command { Command::new("Difftastic") .override_usage(USAGE) .version(env!("CARGO_PKG_VERSION")) @@ -117,7 +117,6 @@ fn app() -> clap::Command<'static> { .arg( Arg::new("dump-syntax") .long("dump-syntax") - .takes_value(true) .value_name("PATH") .action(ArgAction::Set) .long_help( @@ -127,7 +126,6 @@ fn app() -> clap::Command<'static> { .arg( Arg::new("dump-syntax-dot") .long("dump-syntax-dot") - .takes_value(true) .value_name("PATH") .action(ArgAction::Set) .long_help( @@ -137,8 +135,7 @@ fn app() -> clap::Command<'static> { .arg( Arg::new("dump-ts") .long("dump-ts") - .takes_value(true) - .value_name("PATH") + .value_name("PATH") .action(ArgAction::Set) .long_help( "Parse a single file with tree-sitter and display the tree-sitter parse tree.", @@ -147,8 +144,7 @@ fn app() -> clap::Command<'static> { .arg( Arg::new("context") .long("context") - .takes_value(true) - .value_name("LINES") + .value_name("LINES") .action(ArgAction::Set) .long_help("The number of contextual lines to show around changed lines.") .default_value("3") @@ -159,7 +155,6 @@ fn app() -> clap::Command<'static> { .arg( Arg::new("width") .long("width") - .takes_value(true) .value_name("COLUMNS") .action(ArgAction::Set) .long_help("Use this many columns when calculating line wrapping. If not specified, difftastic will detect the terminal width.") @@ -170,7 +165,6 @@ fn app() -> clap::Command<'static> { .arg( Arg::new("tab-width") .long("tab-width") - .takes_value(true) .value_name("NUM_SPACES") .action(ArgAction::Set) .long_help("Treat a tab as this many spaces.") @@ -290,7 +284,6 @@ When multiple overrides are specified, the first matching override wins.")) ) .arg( Arg::new("byte-limit").long("byte-limit") - .takes_value(true) .value_name("LIMIT") .action(ArgAction::Set) .help("Use a text diff if either input file exceeds this size.") @@ -301,7 +294,6 @@ When multiple overrides are specified, the first matching override wins.")) ) .arg( Arg::new("graph-limit").long("graph-limit") - .takes_value(true) .value_name("LIMIT") .help("Use a text diff if the structural graph exceed this number of nodes in memory.") .default_value(formatcp!("{}", DEFAULT_GRAPH_LIMIT)) @@ -312,7 +304,6 @@ When multiple overrides are specified, the first matching override wins.")) ) .arg( Arg::new("parse-error-limit").long("parse-error-limit") - .takes_value(true) .value_name("LIMIT") .action(ArgAction::Set) .help("Use a text diff if the number of parse errors exceeds this value.") @@ -325,7 +316,6 @@ When multiple overrides are specified, the first matching override wins.")) Arg::new("paths") .value_name("PATHS") .action(ArgAction::Append) - .multiple_values(true) .hide(true) .value_parser(value_parser!(OsString)), )