From f17ada2baf2866e90ac1f9d68309ed9b8d8347f8 Mon Sep 17 00:00:00 2001 From: Nora Widdecke Date: Fri, 6 May 2022 17:57:06 +0200 Subject: sq: Port command line handling from clap 2 to 3. Change sq command line handling from using clap version 2 to version 3, and adapt to all the breaking changes. Clap version 3 is a major new version with a number of breaking changes. It also adds functionality to allow a structopt style declarative way of defining command line syntax. We want to use that, but first we need to port the old "builder style" of defining the command line syntax to clap version 3. The change to use the "derive style" comes later. The semantics of clap version 2's .multiple function were hard to understand and it was replaced with .multiple_occurences. Care was taken to preserve the original intention regarding an argument's number of occurrences and number of values. There are some changes to help output (in src/sq-usage.rs). These are mostly from upstream changes and we think the differences are minor so we are okay with following upstream's lead. In summary: FLAGS and OPTIONS are merged into just OPTIONS; the layout of subcommand lists are a little different (split into two lines); there is no "[--]" before filename arguments anymore; default and allowed values for options are on a separate line now; --version isn't repeated for every subcommand anymore; help is listed for each subcommand separately. In addition, we will help clap upstream fix a problem where the help output doesn't have a "..." to indicate that an option may be used several times. Further, upstream has changed --help text to be of the form "Print help", when it earlier was "Prints help". We will change our own help texts to follow suite in a future commit. We don't do it in this commit, to avoid making an even larger diff. By default, clap v3 now colors its help output. However, this does not support custom sections like our examples. Clap is tracking this as https://github.com/clap-rs/clap/issues/3108. In the meantime, disable colors. --- Cargo.lock | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 93 insertions(+), 8 deletions(-) (limited to 'Cargo.lock') diff --git a/Cargo.lock b/Cargo.lock index 566800e7..b6467aad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -414,13 +414,61 @@ dependencies = [ "ansi_term", "atty", "bitflags", - "strsim", - "term_size", + "strsim 0.8.0", "textwrap 0.11.0", "unicode-width", "vec_map", ] +[[package]] +name = "clap" +version = "3.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47582c09be7c8b32c0ab3a6181825ababb713fde6fff20fc573a3870dd45c6a0" +dependencies = [ + "atty", + "bitflags", + "clap_derive", + "clap_lex", + "indexmap", + "lazy_static", + "strsim 0.10.0", + "termcolor", + "terminal_size", + "textwrap 0.15.0", +] + +[[package]] +name = "clap_complete" +version = "3.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da92e6facd8d73c22745a5d3cbb59bdf8e46e3235c923e516527d8e81eec14a4" +dependencies = [ + "clap 3.1.17", +] + +[[package]] +name = "clap_derive" +version = "3.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3aab4734e083b809aaf5794e14e756d1c798d2c69c7f7de7a09a2f5214993c1" +dependencies = [ + "heck 0.4.0", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "cmac" version = "0.5.1" @@ -479,7 +527,7 @@ checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" dependencies = [ "atty", "cast", - "clap", + "clap 2.34.0", "criterion-plot", "csv", "itertools 0.10.3", @@ -1254,6 +1302,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -1873,6 +1927,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "os_str_bytes" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" + [[package]] name = "p256" version = "0.8.1" @@ -2541,7 +2601,7 @@ dependencies = [ "anyhow", "buffered-reader", "capnp-rpc", - "clap", + "clap 2.34.0", "ctor", "dirs", "fs2", @@ -2649,7 +2709,8 @@ dependencies = [ "assert_cmd", "buffered-reader", "chrono", - "clap", + "clap 3.1.17", + "clap_complete", "fehler", "itertools 0.10.3", "predicates", @@ -2903,13 +2964,19 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "structopt" version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ - "clap", + "clap 2.34.0", "lazy_static", "structopt-derive", ] @@ -2920,7 +2987,7 @@ version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ - "heck", + "heck 0.3.3", "proc-macro-error", "proc-macro2", "quote", @@ -3116,6 +3183,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal_size" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "termtree" version = "0.2.4" @@ -3128,7 +3205,6 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ - "term_size", "unicode-width", ] @@ -3143,6 +3219,15 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "textwrap" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" +dependencies = [ + "terminal_size", +] + [[package]] name = "thiserror" version = "1.0.30" -- cgit v1.2.3