From fc66cf0e5917c166989360408d265133020fd510 Mon Sep 17 00:00:00 2001 From: Jeff Vander Stoep Date: Thu, 1 Feb 2024 14:00:33 +0100 Subject: Upgrade clap_complete to 4.4.9 This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update external/rust/crates/clap_complete For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md Test: TreeHugger Change-Id: I8d6c3a390a21c87aed54d0714d84d92cce39db12 --- .cargo_vcs_info.json | 2 +- Android.bp | 2 +- Cargo.lock | 314 ++++++++++++++++++-------------------------- Cargo.toml | 23 +++- Cargo.toml.orig | 14 +- METADATA | 22 ++-- README.md | 8 +- src/dynamic/completer.rs | 4 +- src/dynamic/mod.rs | 2 + src/dynamic/shells/bash.rs | 2 +- src/dynamic/shells/fish.rs | 2 +- src/dynamic/shells/mod.rs | 6 + src/dynamic/shells/shell.rs | 2 +- src/generator/mod.rs | 4 +- src/generator/utils.rs | 2 +- src/lib.rs | 1 + src/shells/bash.rs | 72 ++++++---- 17 files changed, 240 insertions(+), 242 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 2df91bd..cd7d5d4 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "9bfa5a338c6532419e2477e89708395fbb02ca06" + "sha1": "bd9583059be6db26ef07eacbfbd31d634c2cbec6" }, "path_in_vcs": "clap_complete" } \ No newline at end of file diff --git a/Android.bp b/Android.bp index f11d5ad..6f39158 100644 --- a/Android.bp +++ b/Android.bp @@ -7,7 +7,7 @@ rust_library { host_supported: true, crate_name: "clap_complete", cargo_env_compat: true, - cargo_pkg_version: "4.4.4", + cargo_pkg_version: "4.4.9", srcs: ["src/lib.rs"], edition: "2021", features: ["default"], diff --git a/Cargo.lock b/Cargo.lock index 452559b..02b644c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "anstream" -version = "0.6.0" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff2cf94a3dbe2d57cbd56485e1bd7436455058034d6c2d47be51d4e5e4bc6ab" +checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" dependencies = [ "anstyle", "anstyle-parse", @@ -57,12 +57,12 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0238ca56c96dfa37bdf7c373c8886dd591322500aceeeccdb2216fe06dc2f796" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -98,6 +98,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + [[package]] name = "cc" version = "1.0.83" @@ -115,34 +121,33 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.3.0" +version = "4.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc" +checksum = "80932e03c33999b9235edb8655bc9df3204adc9887c2f95b50cb1deb9fd54253" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.0" +version = "4.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" +checksum = "d6c0db58c659eef1c73e444d298c27322a1b52f6927d2ad470c0c0f96fa7b8fa" dependencies = [ "anstyle", "backtrace", - "bitflags", - "clap_lex 0.5.0", + "clap_lex", ] [[package]] name = "clap_complete" -version = "4.4.4" +version = "4.4.9" dependencies = [ "clap", - "clap_lex 0.6.0", + "clap_lex", "completest", + "completest-pty", "is_executable", "pathdiff", "shlex", @@ -153,9 +158,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.0" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191d9573962933b4027f932c600cd252ce27a8ad5979418fe78e43c07996f27b" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", @@ -163,12 +168,6 @@ dependencies = [ "syn", ] -[[package]] -name = "clap_lex" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" - [[package]] name = "clap_lex" version = "0.6.0" @@ -183,10 +182,17 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "completest" -version = "0.1.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8084b60ec7306f1e9b4d855061147a5721eabbd860854213dd69679000cc86c" +checksum = "8229e041ca8f8130ad7f0ce1afb9cfdb3033de7fd548e6422dbb2f4f12184f41" + +[[package]] +name = "completest-pty" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a6d1272e27f608f97616be67a2aed03ed8d73910b5df9a7f4a50c4ffd59d185" dependencies = [ + "completest", "ptyprocess", "vt100", ] @@ -200,16 +206,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.2" @@ -256,24 +252,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" [[package]] -name = "errno" -version = "0.3.2" +name = "equivalent" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] -name = "errno-dragonfly" -version = "0.1.2" +name = "errno" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] @@ -290,12 +281,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.9.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "filetime" @@ -305,7 +293,7 @@ checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.3.5", "windows-sys 0.48.0", ] @@ -323,9 +311,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" [[package]] name = "heck" @@ -333,15 +321,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 = "humantime" version = "2.1.0" @@ -360,33 +339,14 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ - "autocfg", + "equivalent", "hashbrown", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" -dependencies = [ - "libc", - "windows-sys 0.42.0", -] - [[package]] name = "is_executable" version = "1.0.1" @@ -404,15 +364,15 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "linux-raw-sys" -version = "0.3.8" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "log" @@ -425,9 +385,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "memoffset" @@ -462,7 +422,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.7.1", @@ -476,16 +436,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" -[[package]] -name = "num_cpus" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "object" version = "0.30.3" @@ -525,9 +475,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -552,9 +502,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -562,14 +512,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] @@ -578,7 +526,16 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", ] [[package]] @@ -589,16 +546,15 @@ checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" [[package]] name = "rustix" -version = "0.37.7" +version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aae838e49b3d63e9274e1c01833cc8139d3fec468c3b84688c628f44b1ae11d" +checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags", + "bitflags 2.4.0", "errno", - "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.45.0", + "windows-sys 0.52.0", ] [[package]] @@ -676,9 +632,9 @@ checksum = "62ac7f900db32bf3fd12e0117dd3dc4da74bc52ebaac97f39668446d89694803" [[package]] name = "snapbox" -version = "0.4.13" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b439536a42c43be148b610c7f7f968fb79a457254910a9cb20900da73cd3271" +checksum = "c4f1976ee8fd1be27d5f72c98be0aac4397a882a4736935d47418a5fbbd12042" dependencies = [ "anstream", "anstyle", @@ -694,7 +650,7 @@ dependencies = [ "tempfile", "wait-timeout", "walkdir", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -725,15 +681,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.5.0" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", + "redox_syscall 0.4.1", "rustix", - "windows-sys 0.45.0", + "windows-sys 0.52.0", ] [[package]] @@ -747,9 +703,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.9" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d964908cec0d030b812013af25a0e57fddfadb1e066ecc6681d86253129d4f" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ "indexmap", "serde", @@ -760,9 +716,9 @@ dependencies = [ [[package]] name = "trycmd" -version = "0.14.18" +version = "0.14.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5bff680f217f2c7cc246aa5313ef9c1802449b1b8f859d28765355fda1c421f" +checksum = "ed009372a42fb103e6f8767b9222925485e03cca032b700d203e2c5b67bee4fb" dependencies = [ "glob", "humantime", @@ -842,12 +798,11 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.3.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -882,30 +837,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -916,18 +847,12 @@ dependencies = [ ] [[package]] -name = "windows-targets" -version = "0.42.2" +name = "windows-sys" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets 0.52.0", ] [[package]] @@ -946,10 +871,19 @@ dependencies = [ ] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" +name = "windows-targets" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] [[package]] name = "windows_aarch64_gnullvm" @@ -958,10 +892,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" +name = "windows_aarch64_gnullvm" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" [[package]] name = "windows_aarch64_msvc" @@ -970,10 +904,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] -name = "windows_i686_gnu" -version = "0.42.2" +name = "windows_aarch64_msvc" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" [[package]] name = "windows_i686_gnu" @@ -982,10 +916,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] -name = "windows_i686_msvc" -version = "0.42.2" +name = "windows_i686_gnu" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" [[package]] name = "windows_i686_msvc" @@ -994,10 +928,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" +name = "windows_i686_msvc" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" [[package]] name = "windows_x86_64_gnu" @@ -1006,10 +940,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" +name = "windows_x86_64_gnu" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" [[package]] name = "windows_x86_64_gnullvm" @@ -1018,10 +952,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" +name = "windows_x86_64_gnullvm" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" [[package]] name = "windows_x86_64_msvc" @@ -1029,11 +963,17 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winnow" -version = "0.4.6" +version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index d71f151..89f121a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.70.0" name = "clap_complete" -version = "4.4.4" +version = "4.4.9" include = [ "build.rs", "src/**/*", @@ -36,7 +36,16 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/clap-rs/clap/tree/master/clap_complete" [package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] +cargo-args = [ + "-Zunstable-options", + "-Zrustdoc-scrape-examples", +] +features = ["unstable-doc"] +rustdoc-args = [ + "--cfg", + "docsrs", + "--generate-link-to-definition", +] [[package.metadata.release.pre-release-replacements]] file = "CHANGELOG.md" @@ -122,10 +131,13 @@ features = [ default-features = false [dev-dependencies.completest] -version = "0.1.0" +version = "0.4.0" + +[dev-dependencies.completest-pty] +version = "0.5.0" [dev-dependencies.snapbox] -version = "0.4.13" +version = "0.4.15" features = [ "diff", "path", @@ -133,7 +145,7 @@ features = [ ] [dev-dependencies.trycmd] -version = "0.14.18" +version = "0.14.19" features = [ "color-auto", "diff", @@ -144,6 +156,7 @@ default-features = false [features] debug = ["clap/debug"] default = [] +unstable-doc = ["unstable-dynamic"] unstable-dynamic = [ "dep:clap_lex", "dep:shlex", diff --git a/Cargo.toml.orig b/Cargo.toml.orig index c059a33..ce1e99b 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "clap_complete" -version = "4.4.4" +version = "4.4.9" description = "Generate shell completion scripts for your clap::Command" repository = "https://github.com/clap-rs/clap/tree/master/clap_complete" categories = ["command-line-interface"] @@ -16,7 +16,9 @@ rust-version.workspace = true include.workspace = true [package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] +features = ["unstable-doc"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] +cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] [package.metadata.release] pre-release-replacements = [ @@ -40,10 +42,11 @@ shlex = { version = "1.1.0", optional = true } unicode-xid = { version = "0.2.2", optional = true } [dev-dependencies] -snapbox = { version = "0.4.13", features = ["diff", "path", "examples"] } +snapbox = { version = "0.4.15", features = ["diff", "path", "examples"] } # Cutting out `filesystem` feature -trycmd = { version = "0.14.18", default-features = false, features = ["color-auto", "diff", "examples"] } -completest = "0.1.0" +trycmd = { version = "0.14.19", default-features = false, features = ["color-auto", "diff", "examples"] } +completest = "0.4.0" +completest-pty = "0.5.0" clap = { path = "../", version = "4.0.0", default-features = false, features = ["std", "derive", "help"] } [[example]] @@ -52,5 +55,6 @@ required-features = ["unstable-dynamic"] [features] default = [] +unstable-doc = ["unstable-dynamic"] # for docs.rs unstable-dynamic = ["dep:clap_lex", "dep:shlex", "dep:unicode-xid", "clap/derive", "dep:is_executable", "dep:pathdiff"] debug = ["clap/debug"] diff --git a/METADATA b/METADATA index d2f34a9..3fa8034 100644 --- a/METADATA +++ b/METADATA @@ -1,20 +1,24 @@ +# This project was upgraded with external_updater. +# Usage: tools/external_updater/updater.sh update external/rust/crates/clap_complete +# For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md + name: "clap_complete" description: "Generate shell completion scripts for your clap::Command" third_party { + license_type: NOTICE + last_upgrade_date { + year: 2024 + month: 2 + day: 1 + } identifier { type: "crates.io" - value: "https://crates.io/crates/clap_complete" + value: "https://static.crates.io/crates/clap_complete/clap_complete-4.4.9.crate" + version: "4.4.4" } identifier { type: "Archive" value: "https://static.crates.io/crates/clap_complete/clap_complete-4.4.4.crate" - } - version: "4.4.4" - # Dual-licensed, using the least restrictive per go/thirdpartylicenses#same. - license_type: NOTICE - last_upgrade_date { - year: 2023 - month: 11 - day: 20 + version: "4.4.9" } } diff --git a/README.md b/README.md index cc283ce..ab504c2 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,16 @@ [![Crates.io](https://img.shields.io/crates/v/clap_complete?style=flat-square)](https://crates.io/crates/clap_complete) [![Crates.io](https://img.shields.io/crates/d/clap_complete?style=flat-square)](https://crates.io/crates/clap_complete) -[![License](https://img.shields.io/badge/license-Apache%202.0-blue?style=flat-square)](https://github.com/clap-rs/clap/blob/clap_complete-v4.4.4/LICENSE-APACHE) -[![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](https://github.com/clap-rs/clap/blob/clap_complete-v4.4.4/LICENSE-MIT) +[![License](https://img.shields.io/badge/license-Apache%202.0-blue?style=flat-square)](https://github.com/clap-rs/clap/blob/clap_complete-v4.4.9/LICENSE-APACHE) +[![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](https://github.com/clap-rs/clap/blob/clap_complete-v4.4.9/LICENSE-MIT) Dual-licensed under [Apache 2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT). 1. [About](#about) 2. [API Reference](https://docs.rs/clap_complete) 3. [Questions & Discussions](https://github.com/clap-rs/clap/discussions) -4. [CONTRIBUTING](https://github.com/clap-rs/clap/blob/clap_complete-v4.4.4/clap_complete/CONTRIBUTING.md) -5. [Sponsors](https://github.com/clap-rs/clap/blob/clap_complete-v4.4.4/README.md#sponsors) +4. [CONTRIBUTING](https://github.com/clap-rs/clap/blob/clap_complete-v4.4.9/clap_complete/CONTRIBUTING.md) +5. [Sponsors](https://github.com/clap-rs/clap/blob/clap_complete-v4.4.9/README.md#sponsors) ## About diff --git a/src/dynamic/completer.rs b/src/dynamic/completer.rs index 8c8cb93..232dd4b 100644 --- a/src/dynamic/completer.rs +++ b/src/dynamic/completer.rs @@ -16,7 +16,7 @@ pub trait Completer { completer: &str, buf: &mut dyn std::io::Write, ) -> Result<(), std::io::Error>; - /// Complete the command + /// Complete the given command fn write_complete( &self, cmd: &mut clap::Command, @@ -26,7 +26,7 @@ pub trait Completer { ) -> Result<(), std::io::Error>; } -/// Complete the command specified +/// Complete the given command pub fn complete( cmd: &mut clap::Command, args: Vec, diff --git a/src/dynamic/mod.rs b/src/dynamic/mod.rs index f7c9857..ed72565 100644 --- a/src/dynamic/mod.rs +++ b/src/dynamic/mod.rs @@ -1,4 +1,6 @@ //! Complete commands within shells +//! +//! For quick-start, see [`shells::CompleteCommand`] mod completer; diff --git a/src/dynamic/shells/bash.rs b/src/dynamic/shells/bash.rs index 43c128e..1308e67 100644 --- a/src/dynamic/shells/bash.rs +++ b/src/dynamic/shells/bash.rs @@ -1,6 +1,6 @@ use unicode_xid::UnicodeXID as _; -/// Bash completions +/// Completion support for Bash #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct Bash; diff --git a/src/dynamic/shells/fish.rs b/src/dynamic/shells/fish.rs index 9d7e8c6..cfb9519 100644 --- a/src/dynamic/shells/fish.rs +++ b/src/dynamic/shells/fish.rs @@ -1,4 +1,4 @@ -/// Fish completions +/// Completion support for Fish #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct Fish; diff --git a/src/dynamic/shells/mod.rs b/src/dynamic/shells/mod.rs index 54d23a3..6cfed97 100644 --- a/src/dynamic/shells/mod.rs +++ b/src/dynamic/shells/mod.rs @@ -13,20 +13,26 @@ use std::io::Write as _; use crate::dynamic::Completer as _; +/// A subcommand definition to `flatten` into your CLI +/// +/// This provides a one-stop solution for integrating completions into your CLI #[derive(clap::Subcommand)] #[allow(missing_docs)] #[derive(Clone, Debug)] +#[command(about = None, long_about = None)] pub enum CompleteCommand { /// Register shell completions for this program #[command(hide = true)] Complete(CompleteArgs), } +/// Generally used via [`CompleteCommand`] #[derive(clap::Args)] #[command(arg_required_else_help = true)] #[command(group = clap::ArgGroup::new("complete").multiple(true).conflicts_with("register"))] #[allow(missing_docs)] #[derive(Clone, Debug)] +#[command(about = None, long_about = None)] pub struct CompleteArgs { /// Specify shell to complete for #[arg(long)] diff --git a/src/dynamic/shells/shell.rs b/src/dynamic/shells/shell.rs index a9f48ce..c36d2a2 100644 --- a/src/dynamic/shells/shell.rs +++ b/src/dynamic/shells/shell.rs @@ -4,7 +4,7 @@ use std::str::FromStr; use clap::builder::PossibleValue; use clap::ValueEnum; -/// Shell with auto-generated completion script available. +/// Completion support for built-in shells #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] #[non_exhaustive] pub enum Shell { diff --git a/src/generator/mod.rs b/src/generator/mod.rs index a371f68..415913e 100644 --- a/src/generator/mod.rs +++ b/src/generator/mod.rs @@ -36,7 +36,7 @@ pub trait Generator { /// ``` fn file_name(&self, name: &str) -> String; - /// Generates output out of [`clap::Command`](Command). + /// Generates output out of [`clap::Command`]. /// /// # Panics /// @@ -44,7 +44,7 @@ pub trait Generator { /// /// # Examples /// - /// The following example generator displays the [`clap::Command`](Command) + /// The following example generator displays the [`clap::Command`] /// as if it is printed using [`std::println`]. /// /// ``` diff --git a/src/generator/utils.rs b/src/generator/utils.rs index ca76d18..6ea10d2 100644 --- a/src/generator/utils.rs +++ b/src/generator/utils.rs @@ -109,7 +109,7 @@ pub fn longs_and_visible_aliases(p: &Command) -> Vec { .collect() } -/// Gets all the flags of a [`clap::Command`](Command). +/// Gets all the flags of a [`clap::Command`]. /// Includes `help` and `version` depending on the [`clap::Command`] settings. pub fn flags(p: &Command) -> Vec { debug!("flags: name={}", p.get_name()); diff --git a/src/lib.rs b/src/lib.rs index a442882..18fb282 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,7 @@ #![doc(html_logo_url = "https://raw.githubusercontent.com/clap-rs/clap/master/assets/clap.png")] #![doc = include_str!("../README.md")] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![warn(missing_docs, trivial_casts, unused_allocation, trivial_numeric_casts)] #![forbid(unsafe_code)] #![allow(clippy::needless_doctest_main)] diff --git a/src/shells/bash.rs b/src/shells/bash.rs index 2a97e1d..f390853 100644 --- a/src/shells/bash.rs +++ b/src/shells/bash.rs @@ -18,6 +18,8 @@ impl Generator for Bash { .get_bin_name() .expect("crate::generate should have set the bin_name"); + let fn_name = bin_name.replace('-', "__"); + w!( buf, format!( @@ -58,13 +60,17 @@ impl Generator for Bash { esac }} -complete -F _{name} -o nosort -o bashdefault -o default {name} +if [[ \"${{BASH_VERSINFO[0]}}\" -eq 4 && \"${{BASH_VERSINFO[1]}}\" -ge 4 || \"${{BASH_VERSINFO[0]}}\" -gt 4 ]]; then + complete -F _{name} -o nosort -o bashdefault -o default {name} +else + complete -F _{name} -o bashdefault -o default {name} +fi ", name = bin_name, - cmd = bin_name.replace('-', "__"), + cmd = fn_name, name_opts = all_options_for_path(cmd, bin_name), name_opts_details = option_details_for_path(cmd, bin_name), - subcmds = all_subcommands(cmd), + subcmds = all_subcommands(cmd, &fn_name), subcmd_details = subcommand_details(cmd) ) .as_bytes() @@ -72,7 +78,7 @@ complete -F _{name} -o nosort -o bashdefault -o default {name} } } -fn all_subcommands(cmd: &Command) -> String { +fn all_subcommands(cmd: &Command, parent_fn_name: &str) -> String { debug!("all_subcommands"); fn add_command( @@ -102,9 +108,8 @@ fn all_subcommands(cmd: &Command) -> String { } } let mut subcmds = vec![]; - let fn_name = cmd.get_name().replace('-', "__"); for subcmd in cmd.get_subcommands() { - add_command(&fn_name, subcmd, &mut subcmds); + add_command(parent_fn_name, subcmd, &mut subcmds); } subcmds.sort(); @@ -164,29 +169,50 @@ fn option_details_for_path(cmd: &Command, path: &str) -> String { let mut opts = vec![String::new()]; for o in p.get_opts() { + let compopt = match o.get_value_hint() { + ValueHint::FilePath => Some("compopt -o filenames"), + ValueHint::DirPath => Some("compopt -o plusdirs"), + ValueHint::Other => Some("compopt -o nospace"), + _ => None, + }; + if let Some(longs) = o.get_long_and_visible_aliases() { opts.extend(longs.iter().map(|long| { - format!( - "--{}) - COMPREPLY=({}) - return 0 - ;;", - long, - vals_for(o) - ) + let mut v = vec![ + format!("--{})", long), + format!("COMPREPLY=({})", vals_for(o)), + ]; + + if let Some(copt) = compopt { + v.extend([ + r#"if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then"#.to_string(), + format!(" {}", copt), + "fi".to_string(), + ]); + } + + v.extend(["return 0", ";;"].iter().map(|s| s.to_string())); + v.join("\n ") })); } if let Some(shorts) = o.get_short_and_visible_aliases() { opts.extend(shorts.iter().map(|short| { - format!( - "-{}) - COMPREPLY=({}) - return 0 - ;;", - short, - vals_for(o) - ) + let mut v = vec![ + format!("-{})", short), + format!("COMPREPLY=({})", vals_for(o)), + ]; + + if let Some(copt) = compopt { + v.extend([ + r#"if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then"#.to_string(), + format!(" {}", copt), + "fi".to_string(), + ]); + } + + v.extend(["return 0", ";;"].iter().map(|s| s.to_string())); + v.join("\n ") })); } } @@ -206,6 +232,8 @@ fn vals_for(o: &Arg) -> String { .collect::>() .join(" ") ) + } else if o.get_value_hint() == ValueHint::DirPath { + String::from("") // should be empty to avoid duplicate candidates } else if o.get_value_hint() == ValueHint::Other { String::from("\"${cur}\"") } else { -- cgit v1.2.3