diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 05:48:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 05:48:42 +0000 |
commit | cec1877e180393eba0f6ddb0cf97bf3a791631c7 (patch) | |
tree | 47b4dac2a9dd9a40c30c251b4d4a72d7ccf77e9f /vendor/clap_complete | |
parent | Adding debian version 1.74.1+dfsg1-1. (diff) | |
download | rustc-cec1877e180393eba0f6ddb0cf97bf3a791631c7.tar.xz rustc-cec1877e180393eba0f6ddb0cf97bf3a791631c7.zip |
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/clap_complete')
-rw-r--r-- | vendor/clap_complete/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/clap_complete/Cargo.lock | 355 | ||||
-rw-r--r-- | vendor/clap_complete/Cargo.toml | 17 | ||||
-rw-r--r-- | vendor/clap_complete/README.md | 8 | ||||
-rw-r--r-- | vendor/clap_complete/examples/dynamic.rs | 4 | ||||
-rw-r--r-- | vendor/clap_complete/examples/exhaustive.rs | 203 | ||||
-rw-r--r-- | vendor/clap_complete/src/dynamic.rs | 549 | ||||
-rw-r--r-- | vendor/clap_complete/src/dynamic/completer.rs | 341 | ||||
-rw-r--r-- | vendor/clap_complete/src/dynamic/mod.rs | 7 | ||||
-rw-r--r-- | vendor/clap_complete/src/dynamic/shells/bash.rs | 121 | ||||
-rw-r--r-- | vendor/clap_complete/src/dynamic/shells/fish.rs | 46 | ||||
-rw-r--r-- | vendor/clap_complete/src/dynamic/shells/mod.rs | 82 | ||||
-rw-r--r-- | vendor/clap_complete/src/dynamic/shells/shell.rs | 85 | ||||
-rw-r--r-- | vendor/clap_complete/src/shells/bash.rs | 2 | ||||
-rw-r--r-- | vendor/clap_complete/src/shells/fish.rs | 6 | ||||
-rw-r--r-- | vendor/clap_complete/src/shells/powershell.rs | 4 |
16 files changed, 1182 insertions, 650 deletions
diff --git a/vendor/clap_complete/.cargo-checksum.json b/vendor/clap_complete/.cargo-checksum.json index 6450aa7f9..0386d8294 100644 --- a/vendor/clap_complete/.cargo-checksum.json +++ b/vendor/clap_complete/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.lock":"459c4073d0c76c4838fbdf7b5e341d0bb24d919098a9a5c9ae0a8ea035957080","Cargo.toml":"da0fb52fa6fc22c4a5f3b7e97f8fcdfb8cbb2712f0319a768a13a5fc289c3d68","LICENSE-APACHE":"c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4","LICENSE-MIT":"0d687e1f07b58fe68bda74668ff6326125e5e5efa184cce755cd84ac535b7058","README.md":"7292d866750439d0bd43b4833d02fe681e1097602a2647bbdad5705c39ea4e74","examples/completion-derive.rs":"9df678ff1b67b7e8e829d53d983960429eb809aac4e72f4c5415a59cee8684a6","examples/completion.rs":"d81c0281ae87280d40381e468c0fa2bb4d8751022fdfd0d11ed9d54598e18d8d","examples/dynamic.rs":"47c023b8d684e39bd95d1837dcbe3980ff29d3c3b19c685f3029c3fa260b882e","src/dynamic.rs":"4577d56abe90307a9e2c3189f3d96d2eaaff6639c07aa411eaa814c396d195f5","src/generator/mod.rs":"054bc08444ee7389168bcd74954c0ac448df186ddf2c8491dca01aff2456b6d7","src/generator/utils.rs":"2486cdfc9edf1678fed953080ce48b3350e7b4a2f29e7e3a681b64d621f40f47","src/lib.rs":"8ad5e4171dd7ba9dbad24c7e8c90bdf0444a8cc427fe8e5ce2b6407d0dc018ac","src/macros.rs":"8445231263f03893ab3806e3f50747113bf8d638bd81e2a6bf33c9a0df224421","src/shells/bash.rs":"d5d4cef101f0742a8695a7036a4b63151f86225d70898c500ddb0e739b682c4e","src/shells/elvish.rs":"c09e570414213f779b2126eb33784bc39774269ffe4a0654fc32e17d4ac649ae","src/shells/fish.rs":"2266faee22d38f3886792ac14e589cb2a3859593f779789fd4903f3ba6cb10c2","src/shells/mod.rs":"002352299be1ece75540e7b1502120590f4635f69a925b19484d272bd5491505","src/shells/powershell.rs":"d6e4e93afecd6c765fbe2438159a9b11de76c696a5b89d85ec279fb79e43e7d5","src/shells/shell.rs":"4dd9df0bd1f371da370c66808d16ad00a045ba3b997844b1164518b094bba951","src/shells/zsh.rs":"bf73a3253dfc023f1704d8ab28efbf5aa17e390a0fa337eebd3369684857a118"},"package":"7f6b5c519bab3ea61843a7923d074b04245624bb84a64a8c150f5deb014e388b"}
\ No newline at end of file +{"files":{"Cargo.lock":"40ae0595e56e26762bea08190bec066f169116d12ca1ef54f16026db6241aa88","Cargo.toml":"a4058f4f3fc85bb43cd265899209c6a0e0150d7d5bca688f3c414534aff33a08","LICENSE-APACHE":"c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4","LICENSE-MIT":"0d687e1f07b58fe68bda74668ff6326125e5e5efa184cce755cd84ac535b7058","README.md":"c16463f56e2dae5b976ca630c2e5399ed8357865dcd361ce3863733bf561ad83","examples/completion-derive.rs":"9df678ff1b67b7e8e829d53d983960429eb809aac4e72f4c5415a59cee8684a6","examples/completion.rs":"d81c0281ae87280d40381e468c0fa2bb4d8751022fdfd0d11ed9d54598e18d8d","examples/dynamic.rs":"0fa838cd9b5f406b5adb467827be43120752673f8d8eca011a01a3e91f26678b","examples/exhaustive.rs":"3acc2b4c1591b0488c721fbff4bb4bbd8d71b58ce3534d82d41f6b2977aff054","src/dynamic/completer.rs":"fb304b3348eb0cc0849cefcd918715612ed3823d67de75368c6d71374ebe7562","src/dynamic/mod.rs":"99e6cf37f53f22394c827bf872801fd93ecc4dffc0e618fdc71d6a04890deaa6","src/dynamic/shells/bash.rs":"359e180a9c5a74a1b3c4e72f25c767d7df4fd93bf589b927dc83b6d35b699b80","src/dynamic/shells/fish.rs":"9575092d165e4a9c52c599f0c143ded40418b4ba9e3400f423e4836925ff2f4e","src/dynamic/shells/mod.rs":"3f1dbdba2cae6bc3eea708a8a264e8e8cfa752c2b00a29054ae1dcd6e860bcd5","src/dynamic/shells/shell.rs":"2e98ba5d9405bd41efeb9982e7b7b4aa5f5ee650b19c79e7c38b068c01c2d7c3","src/generator/mod.rs":"054bc08444ee7389168bcd74954c0ac448df186ddf2c8491dca01aff2456b6d7","src/generator/utils.rs":"2486cdfc9edf1678fed953080ce48b3350e7b4a2f29e7e3a681b64d621f40f47","src/lib.rs":"8ad5e4171dd7ba9dbad24c7e8c90bdf0444a8cc427fe8e5ce2b6407d0dc018ac","src/macros.rs":"8445231263f03893ab3806e3f50747113bf8d638bd81e2a6bf33c9a0df224421","src/shells/bash.rs":"5b60f9ebb995dfa4858eed9615efbffa0cd81842479a701b13374a5047aef22a","src/shells/elvish.rs":"c09e570414213f779b2126eb33784bc39774269ffe4a0654fc32e17d4ac649ae","src/shells/fish.rs":"52007ac76cd4275f128ab46b1df6aa1fe7534d253f0df93d13a19e16c32567c9","src/shells/mod.rs":"002352299be1ece75540e7b1502120590f4635f69a925b19484d272bd5491505","src/shells/powershell.rs":"26137941c89029b493a04667ce45ff705c960f10c8df0b725110708b79c120e2","src/shells/shell.rs":"4dd9df0bd1f371da370c66808d16ad00a045ba3b997844b1164518b094bba951","src/shells/zsh.rs":"bf73a3253dfc023f1704d8ab28efbf5aa17e390a0fa337eebd3369684857a118"},"package":"e3ae8ba90b9d8b007efe66e55e48fb936272f5ca00349b5b0e89877520d35ea7"}
\ No newline at end of file diff --git a/vendor/clap_complete/Cargo.lock b/vendor/clap_complete/Cargo.lock index baabc4700..bef75813b 100644 --- a/vendor/clap_complete/Cargo.lock +++ b/vendor/clap_complete/Cargo.lock @@ -19,30 +19,29 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "anstream" -version = "0.3.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371" +checksum = "bff2cf94a3dbe2d57cbd56485e1bd7436455058034d6c2d47be51d4e5e4bc6ab" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" [[package]] name = "anstyle-parse" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ "utf8parse", ] @@ -58,15 +57,21 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd" +checksum = "0238ca56c96dfa37bdf7c373c8886dd591322500aceeeccdb2216fe06dc2f796" dependencies = [ "anstyle", "windows-sys 0.48.0", ] [[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -95,9 +100,12 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -130,10 +138,11 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.3.1" +version = "4.4.3" dependencies = [ "clap", "clap_lex", + "completest", "is_executable", "pathdiff", "shlex", @@ -167,6 +176,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] +name = "completest" +version = "0.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce6edca5001784bf331c3e712f9098a9346debeded6611206ed921a3f704474" +dependencies = [ + "ptyprocess", + "vt100", +] + +[[package]] +name = "content_inspector" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7bda66e858c683005a53a9a60c69a4aca7eeaa45d124526e389f7aec8e62f38" +dependencies = [ + "memchr", +] + +[[package]] name = "crossbeam-channel" version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -196,7 +224,7 @@ dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset", + "memoffset 0.6.5", "scopeguard", ] @@ -210,6 +238,12 @@ dependencies = [ ] [[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + +[[package]] name = "either" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -217,9 +251,9 @@ checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" [[package]] name = "errno" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" dependencies = [ "errno-dragonfly", "libc", @@ -249,6 +283,27 @@ dependencies = [ ] [[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "filetime" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "windows-sys 0.48.0", +] + +[[package]] name = "gimli" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -268,9 +323,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" @@ -282,12 +337,6 @@ dependencies = [ ] [[package]] -name = "hermit-abi" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" - -[[package]] name = "humantime" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -314,25 +363,22 @@ dependencies = [ ] [[package]] -name = "io-lifetimes" -version = "1.0.3" +name = "instant" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "libc", - "windows-sys 0.42.0", + "cfg-if", ] [[package]] -name = "is-terminal" -version = "0.4.7" +name = "io-lifetimes" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", - "rustix", - "windows-sys 0.48.0", + "libc", + "windows-sys 0.42.0", ] [[package]] @@ -346,15 +392,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.4" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "libc" -version = "0.2.144" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "linux-raw-sys" @@ -387,6 +433,15 @@ dependencies = [ ] [[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + +[[package]] name = "miniz_oxide" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -396,6 +451,20 @@ dependencies = [ ] [[package]] +name = "nix" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" +dependencies = [ + "bitflags", + "cfg-if", + "libc", + "memoffset 0.7.1", + "pin-utils", + "static_assertions", +] + +[[package]] name = "normalize-line-endings" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -407,7 +476,7 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi", "libc", ] @@ -422,9 +491,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "os_pipe" @@ -443,19 +512,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] name = "proc-macro2" -version = "1.0.58" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa1fb82fc0c281dd9671101b66b771ebbe1eaf967b96ac8740dcba4b70005ca8" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] +name = "ptyprocess" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e05aef7befb11a210468a2d77d978dde2c6381a0381e33beb575e91f57fe8cf" +dependencies = [ + "nix", +] + +[[package]] name = "quote" -version = "1.0.26" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -483,6 +567,15 @@ dependencies = [ ] [[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + +[[package]] name = "rustc-demangle" version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -509,6 +602,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -516,18 +618,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.158" +version = "1.0.180" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" +checksum = "0ea67f183f058fe88a4e3ec6e2788e003840893b91bac4559cabedd00863b3ed" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.158" +version = "1.0.180" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" +checksum = "24e744d7782b686ab3b73267ef05697159cc0e5abbed3f47f9933165e5219036" dependencies = [ "proc-macro2", "quote", @@ -536,9 +638,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.87" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" dependencies = [ "itoa", "ryu", @@ -568,36 +670,47 @@ checksum = "62ac7f900db32bf3fd12e0117dd3dc4da74bc52ebaac97f39668446d89694803" [[package]] name = "snapbox" -version = "0.4.11" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6bccd62078347f89a914e3004d94582e13824d4e3d8a816317862884c423835" +checksum = "7b439536a42c43be148b610c7f7f968fb79a457254910a9cb20900da73cd3271" dependencies = [ "anstream", "anstyle", + "content_inspector", + "dunce", "escargot", + "filetime", "libc", "normalize-line-endings", "os_pipe", "similar", "snapbox-macros", + "tempfile", "wait-timeout", - "windows-sys 0.45.0", + "walkdir", + "windows-sys 0.48.0", ] [[package]] name = "snapbox-macros" -version = "0.3.4" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaaf09df9f0eeae82be96290918520214530e738a7fe5a351b0f24cf77c0ca31" +checksum = "ed1559baff8a696add3322b9be3e940d433e7bb4e38d79017205fd37ff28b28e" dependencies = [ "anstream", ] [[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] name = "syn" -version = "2.0.16" +version = "2.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" +checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" dependencies = [ "proc-macro2", "quote", @@ -605,6 +718,19 @@ dependencies = [ ] [[package]] +name = "tempfile" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall", + "rustix", + "windows-sys 0.45.0", +] + +[[package]] name = "toml_datetime" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -628,9 +754,9 @@ dependencies = [ [[package]] name = "trycmd" -version = "0.14.16" +version = "0.14.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2925e71868a12b173c1eb166018c2d2f9dfaedfcaec747bdb6ea2246785d258e" +checksum = "a5bff680f217f2c7cc246aa5313ef9c1802449b1b8f859d28765355fda1c421f" dependencies = [ "glob", "humantime", @@ -649,6 +775,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] name = "unicode-xid" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -661,6 +793,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] +name = "vt100" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84cd863bf0db7e392ba3bd04994be3473491b31e66340672af5d11943c6274de" +dependencies = [ + "itoa", + "log", + "unicode-width", + "vte", +] + +[[package]] +name = "vte" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5022b5fbf9407086c180e9557be968742d839e68346af7792b8592489732197" +dependencies = [ + "arrayvec", + "utf8parse", + "vte_generate_state_changes", +] + +[[package]] +name = "vte_generate_state_changes" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] name = "wait-timeout" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -670,6 +835,17 @@ dependencies = [ ] [[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + +[[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -686,6 +862,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -721,7 +906,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.5", ] [[package]] @@ -741,17 +926,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -762,9 +947,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" @@ -774,9 +959,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" @@ -786,9 +971,9 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" @@ -798,9 +983,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" @@ -810,9 +995,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" @@ -822,9 +1007,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" @@ -834,9 +1019,9 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" diff --git a/vendor/clap_complete/Cargo.toml b/vendor/clap_complete/Cargo.toml index a1a1f95f9..442371d29 100644 --- a/vendor/clap_complete/Cargo.toml +++ b/vendor/clap_complete/Cargo.toml @@ -11,9 +11,9 @@ [package] edition = "2021" -rust-version = "1.64.0" +rust-version = "1.70.0" name = "clap_complete" -version = "4.3.1" +version = "4.4.3" include = [ "build.rs", "src/**/*", @@ -121,12 +121,19 @@ features = [ ] default-features = false +[dev-dependencies.completest] +version = "0.0.20" + [dev-dependencies.snapbox] -version = "0.4.11" -features = ["diff"] +version = "0.4.13" +features = [ + "diff", + "path", + "examples", +] [dev-dependencies.trycmd] -version = "0.14.16" +version = "0.14.18" features = [ "color-auto", "diff", diff --git a/vendor/clap_complete/README.md b/vendor/clap_complete/README.md index 4713a3887..b09fbd7a3 100644 --- a/vendor/clap_complete/README.md +++ b/vendor/clap_complete/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.3.1/LICENSE-APACHE) -[![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](https://github.com/clap-rs/clap/blob/clap_complete-v4.3.1/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.3/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.3/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.3.1/clap_complete/CONTRIBUTING.md) -5. [Sponsors](https://github.com/clap-rs/clap/blob/clap_complete-v4.3.1/README.md#sponsors) +4. [CONTRIBUTING](https://github.com/clap-rs/clap/blob/clap_complete-v4.4.3/clap_complete/CONTRIBUTING.md) +5. [Sponsors](https://github.com/clap-rs/clap/blob/clap_complete-v4.4.3/README.md#sponsors) ## About diff --git a/vendor/clap_complete/examples/dynamic.rs b/vendor/clap_complete/examples/dynamic.rs index 5f1f30acd..ccaf7d8ad 100644 --- a/vendor/clap_complete/examples/dynamic.rs +++ b/vendor/clap_complete/examples/dynamic.rs @@ -16,14 +16,14 @@ fn command() -> clap::Command { .value_parser(["json", "yaml", "toml"]), ) .args_conflicts_with_subcommands(true); - clap_complete::dynamic::bash::CompleteCommand::augment_subcommands(cmd) + clap_complete::dynamic::shells::CompleteCommand::augment_subcommands(cmd) } fn main() { let cmd = command(); let matches = cmd.get_matches(); if let Ok(completions) = - clap_complete::dynamic::bash::CompleteCommand::from_arg_matches(&matches) + clap_complete::dynamic::shells::CompleteCommand::from_arg_matches(&matches) { completions.complete(&mut command()); } else { diff --git a/vendor/clap_complete/examples/exhaustive.rs b/vendor/clap_complete/examples/exhaustive.rs new file mode 100644 index 000000000..de00da622 --- /dev/null +++ b/vendor/clap_complete/examples/exhaustive.rs @@ -0,0 +1,203 @@ +use clap::builder::PossibleValue; +#[cfg(feature = "unstable-dynamic")] +use clap::{FromArgMatches, Subcommand}; +use clap_complete::{generate, Generator, Shell}; + +fn main() { + let matches = cli().get_matches(); + if let Some(generator) = matches.get_one::<Shell>("generate") { + let mut cmd = cli(); + eprintln!("Generating completion file for {generator}..."); + print_completions(*generator, &mut cmd); + return; + } + + #[cfg(feature = "unstable-dynamic")] + if let Ok(completions) = + clap_complete::dynamic::shells::CompleteCommand::from_arg_matches(&matches) + { + completions.complete(&mut cli()); + return; + }; + + println!("{:?}", matches); +} + +fn print_completions<G: Generator>(gen: G, cmd: &mut clap::Command) { + generate(gen, cmd, cmd.get_name().to_string(), &mut std::io::stdout()); +} + +#[allow(clippy::let_and_return)] +fn cli() -> clap::Command { + let cli = clap::Command::new("exhaustive") + .version("3.0") + .propagate_version(true) + .args([ + clap::Arg::new("global") + .long("global") + .global(true) + .action(clap::ArgAction::SetTrue) + .help("everywhere"), + clap::Arg::new("generate") + .long("generate") + .value_name("SHELL") + .value_parser(clap::value_parser!(Shell)) + .help("generate"), + ]) + .subcommands([ + clap::Command::new("action").args([ + clap::Arg::new("set-true") + .long("set-true") + .action(clap::ArgAction::SetTrue) + .help("bool"), + clap::Arg::new("set") + .long("set") + .action(clap::ArgAction::Set) + .help("value"), + clap::Arg::new("count") + .long("count") + .action(clap::ArgAction::Count) + .help("number"), + clap::Arg::new("choice") + .long("choice") + .value_parser(["first", "second"]) + .help("enum"), + ]), + clap::Command::new("quote") + .args([ + clap::Arg::new("single-quotes") + .long("single-quotes") + .action(clap::ArgAction::SetTrue) + .help("Can be 'always', 'auto', or 'never'"), + clap::Arg::new("double-quotes") + .long("double-quotes") + .action(clap::ArgAction::SetTrue) + .help("Can be \"always\", \"auto\", or \"never\""), + clap::Arg::new("backticks") + .long("backticks") + .action(clap::ArgAction::SetTrue) + .help("For more information see `echo test`"), + clap::Arg::new("backslash") + .long("backslash") + .action(clap::ArgAction::SetTrue) + .help("Avoid '\\n'"), + clap::Arg::new("brackets") + .long("brackets") + .action(clap::ArgAction::SetTrue) + .help("List packages [filter]"), + clap::Arg::new("expansions") + .long("expansions") + .action(clap::ArgAction::SetTrue) + .help("Execute the shell command with $SHELL"), + clap::Arg::new("choice") + .long("choice") + .action(clap::ArgAction::Set) + .value_parser(clap::builder::PossibleValuesParser::new([ + PossibleValue::new("bash").help("bash (shell)"), + PossibleValue::new("fish").help("fish shell"), + PossibleValue::new("zsh").help("zsh shell"), + ])), + ]) + .subcommands([ + clap::Command::new("cmd-single-quotes") + .about("Can be 'always', 'auto', or 'never'"), + clap::Command::new("cmd-double-quotes") + .about("Can be \"always\", \"auto\", or \"never\""), + clap::Command::new("cmd-backticks") + .about("For more information see `echo test`"), + clap::Command::new("cmd-backslash").about("Avoid '\\n'"), + clap::Command::new("cmd-brackets").about("List packages [filter]"), + clap::Command::new("cmd-expansions") + .about("Execute the shell command with $SHELL"), + clap::Command::new("escape-help").about("\\tab\t\"'\nNew Line"), + ]), + clap::Command::new("value").args([ + clap::Arg::new("delim").long("delim").value_delimiter(','), + clap::Arg::new("tuple").long("tuple").num_args(2), + clap::Arg::new("require-eq") + .long("require-eq") + .require_equals(true), + clap::Arg::new("term").num_args(1..).value_terminator(";"), + ]), + clap::Command::new("pacman").subcommands([ + clap::Command::new("one").long_flag("one").short_flag('o'), + clap::Command::new("two").long_flag("two").short_flag('t'), + ]), + clap::Command::new("last") + .args([clap::Arg::new("first"), clap::Arg::new("free").last(true)]), + clap::Command::new("alias").args([ + clap::Arg::new("flag") + .short('f') + .visible_short_alias('F') + .long("flag") + .action(clap::ArgAction::SetTrue) + .visible_alias("flg") + .help("cmd flag"), + clap::Arg::new("option") + .short('o') + .visible_short_alias('O') + .long("option") + .visible_alias("opt") + .help("cmd option") + .action(clap::ArgAction::Set), + clap::Arg::new("positional"), + ]), + clap::Command::new("hint").args([ + clap::Arg::new("choice") + .long("choice") + .action(clap::ArgAction::Set) + .value_parser(["bash", "fish", "zsh"]), + clap::Arg::new("unknown") + .long("unknown") + .value_hint(clap::ValueHint::Unknown), + clap::Arg::new("other") + .long("other") + .value_hint(clap::ValueHint::Other), + clap::Arg::new("path") + .long("path") + .short('p') + .value_hint(clap::ValueHint::AnyPath), + clap::Arg::new("file") + .long("file") + .short('f') + .value_hint(clap::ValueHint::FilePath), + clap::Arg::new("dir") + .long("dir") + .short('d') + .value_hint(clap::ValueHint::DirPath), + clap::Arg::new("exe") + .long("exe") + .short('e') + .value_hint(clap::ValueHint::ExecutablePath), + clap::Arg::new("cmd_name") + .long("cmd-name") + .value_hint(clap::ValueHint::CommandName), + clap::Arg::new("cmd") + .long("cmd") + .short('c') + .value_hint(clap::ValueHint::CommandString), + clap::Arg::new("command_with_args") + .action(clap::ArgAction::Set) + .num_args(1..) + .trailing_var_arg(true) + .value_hint(clap::ValueHint::CommandWithArguments), + clap::Arg::new("user") + .short('u') + .long("user") + .value_hint(clap::ValueHint::Username), + clap::Arg::new("host") + .short('H') + .long("host") + .value_hint(clap::ValueHint::Hostname), + clap::Arg::new("url") + .long("url") + .value_hint(clap::ValueHint::Url), + clap::Arg::new("email") + .long("email") + .value_hint(clap::ValueHint::EmailAddress), + ]), + ]); + #[cfg(feature = "unstable-dynamic")] + let cli = clap_complete::dynamic::shells::CompleteCommand::augment_subcommands(cli); + cli +} diff --git a/vendor/clap_complete/src/dynamic.rs b/vendor/clap_complete/src/dynamic.rs deleted file mode 100644 index f25b4a48d..000000000 --- a/vendor/clap_complete/src/dynamic.rs +++ /dev/null @@ -1,549 +0,0 @@ -//! Complete commands within shells - -/// Complete commands within bash -pub mod bash { - use std::ffi::OsStr; - use std::ffi::OsString; - use std::io::Write; - - use clap_lex::OsStrExt as _; - use unicode_xid::UnicodeXID; - - #[derive(clap::Subcommand)] - #[command(hide = true)] - #[allow(missing_docs)] - #[derive(Clone, Debug)] - pub enum CompleteCommand { - /// Register shell completions for this program - Complete(CompleteArgs), - } - - #[derive(clap::Args)] - #[command(group = clap::ArgGroup::new("complete").multiple(true).conflicts_with("register"))] - #[allow(missing_docs)] - #[derive(Clone, Debug)] - pub struct CompleteArgs { - /// Path to write completion-registration to - #[arg(long, required = true)] - register: Option<std::path::PathBuf>, - - #[arg( - long, - required = true, - value_name = "COMP_CWORD", - hide_short_help = true, - group = "complete" - )] - index: Option<usize>, - - #[arg(long, hide_short_help = true, group = "complete")] - ifs: Option<String>, - - #[arg( - long = "type", - required = true, - hide_short_help = true, - group = "complete" - )] - comp_type: Option<CompType>, - - #[arg(long, hide_short_help = true, group = "complete")] - space: bool, - - #[arg( - long, - conflicts_with = "space", - hide_short_help = true, - group = "complete" - )] - no_space: bool, - - #[arg(raw = true, hide_short_help = true, group = "complete")] - comp_words: Vec<OsString>, - } - - impl CompleteCommand { - /// Process the completion request - pub fn complete(&self, cmd: &mut clap::Command) -> std::convert::Infallible { - self.try_complete(cmd).unwrap_or_else(|e| e.exit()); - std::process::exit(0) - } - - /// Process the completion request - pub fn try_complete(&self, cmd: &mut clap::Command) -> clap::error::Result<()> { - debug!("CompleteCommand::try_complete: {self:?}"); - let CompleteCommand::Complete(args) = self; - if let Some(out_path) = args.register.as_deref() { - let mut buf = Vec::new(); - let name = cmd.get_name(); - let bin = cmd.get_bin_name().unwrap_or_else(|| cmd.get_name()); - register(name, [bin], bin, &Behavior::default(), &mut buf)?; - if out_path == std::path::Path::new("-") { - std::io::stdout().write_all(&buf)?; - } else if out_path.is_dir() { - let out_path = out_path.join(file_name(name)); - std::fs::write(out_path, buf)?; - } else { - std::fs::write(out_path, buf)?; - } - } else { - let index = args.index.unwrap_or_default(); - let comp_type = args.comp_type.unwrap_or_default(); - let space = match (args.space, args.no_space) { - (true, false) => Some(true), - (false, true) => Some(false), - (true, true) => { - unreachable!("`--space` and `--no-space` set, clap should prevent this") - } - (false, false) => None, - } - .unwrap(); - let current_dir = std::env::current_dir().ok(); - let completions = complete( - cmd, - args.comp_words.clone(), - index, - comp_type, - space, - current_dir.as_deref(), - )?; - - let mut buf = Vec::new(); - for (i, completion) in completions.iter().enumerate() { - if i != 0 { - write!(&mut buf, "{}", args.ifs.as_deref().unwrap_or("\n"))?; - } - write!(&mut buf, "{}", completion.to_string_lossy())?; - } - std::io::stdout().write_all(&buf)?; - } - - Ok(()) - } - } - - /// The recommended file name for the registration code - pub fn file_name(name: &str) -> String { - format!("{name}.bash") - } - - /// Define the completion behavior - pub enum Behavior { - /// Bare bones behavior - Minimal, - /// Fallback to readline behavior when no matches are generated - Readline, - /// Customize bash's completion behavior - Custom(String), - } - - impl Default for Behavior { - fn default() -> Self { - Self::Readline - } - } - - /// Generate code to register the dynamic completion - pub fn register( - name: &str, - executables: impl IntoIterator<Item = impl AsRef<str>>, - completer: &str, - behavior: &Behavior, - buf: &mut dyn Write, - ) -> Result<(), std::io::Error> { - let escaped_name = name.replace('-', "_"); - debug_assert!( - escaped_name.chars().all(|c| c.is_xid_continue()), - "`name` must be an identifier, got `{escaped_name}`" - ); - let mut upper_name = escaped_name.clone(); - upper_name.make_ascii_uppercase(); - - let executables = executables - .into_iter() - .map(|s| shlex::quote(s.as_ref()).into_owned()) - .collect::<Vec<_>>() - .join(" "); - - let options = match behavior { - Behavior::Minimal => "-o nospace -o bashdefault", - Behavior::Readline => "-o nospace -o default -o bashdefault", - Behavior::Custom(c) => c.as_str(), - }; - - let completer = shlex::quote(completer); - - let script = r#" -_clap_complete_NAME() { - local IFS=$'\013' - local SUPPRESS_SPACE=0 - if compopt +o nospace 2> /dev/null; then - SUPPRESS_SPACE=1 - fi - if [[ ${SUPPRESS_SPACE} == 1 ]]; then - SPACE_ARG="--no-space" - else - SPACE_ARG="--space" - fi - COMPREPLY=( $("COMPLETER" complete --index ${COMP_CWORD} --type ${COMP_TYPE} ${SPACE_ARG} --ifs="$IFS" -- "${COMP_WORDS[@]}") ) - if [[ $? != 0 ]]; then - unset COMPREPLY - elif [[ $SUPPRESS_SPACE == 1 ]] && [[ "${COMPREPLY-}" =~ [=/:]$ ]]; then - compopt -o nospace - fi -} -complete OPTIONS -F _clap_complete_NAME EXECUTABLES -"# - .replace("NAME", &escaped_name) - .replace("EXECUTABLES", &executables) - .replace("OPTIONS", options) - .replace("COMPLETER", &completer) - .replace("UPPER", &upper_name); - - writeln!(buf, "{script}")?; - Ok(()) - } - - /// Type of completion attempted that caused a completion function to be called - #[derive(Copy, Clone, Debug, PartialEq, Eq)] - #[non_exhaustive] - pub enum CompType { - /// Normal completion - Normal, - /// List completions after successive tabs - Successive, - /// List alternatives on partial word completion - Alternatives, - /// List completions if the word is not unmodified - Unmodified, - /// Menu completion - Menu, - } - - impl clap::ValueEnum for CompType { - fn value_variants<'a>() -> &'a [Self] { - &[ - Self::Normal, - Self::Successive, - Self::Alternatives, - Self::Unmodified, - Self::Menu, - ] - } - fn to_possible_value(&self) -> ::std::option::Option<clap::builder::PossibleValue> { - match self { - Self::Normal => { - let value = "9"; - debug_assert_eq!(b'\t'.to_string(), value); - Some( - clap::builder::PossibleValue::new(value) - .alias("normal") - .help("Normal completion"), - ) - } - Self::Successive => { - let value = "63"; - debug_assert_eq!(b'?'.to_string(), value); - Some( - clap::builder::PossibleValue::new(value) - .alias("successive") - .help("List completions after successive tabs"), - ) - } - Self::Alternatives => { - let value = "33"; - debug_assert_eq!(b'!'.to_string(), value); - Some( - clap::builder::PossibleValue::new(value) - .alias("alternatives") - .help("List alternatives on partial word completion"), - ) - } - Self::Unmodified => { - let value = "64"; - debug_assert_eq!(b'@'.to_string(), value); - Some( - clap::builder::PossibleValue::new(value) - .alias("unmodified") - .help("List completions if the word is not unmodified"), - ) - } - Self::Menu => { - let value = "37"; - debug_assert_eq!(b'%'.to_string(), value); - Some( - clap::builder::PossibleValue::new(value) - .alias("menu") - .help("Menu completion"), - ) - } - } - } - } - - impl Default for CompType { - fn default() -> Self { - Self::Normal - } - } - - /// Complete the command specified - pub fn complete( - cmd: &mut clap::Command, - args: Vec<std::ffi::OsString>, - arg_index: usize, - _comp_type: CompType, - _trailing_space: bool, - current_dir: Option<&std::path::Path>, - ) -> Result<Vec<std::ffi::OsString>, std::io::Error> { - cmd.build(); - - let raw_args = clap_lex::RawArgs::new(args.into_iter()); - let mut cursor = raw_args.cursor(); - let mut target_cursor = raw_args.cursor(); - raw_args.seek( - &mut target_cursor, - clap_lex::SeekFrom::Start(arg_index as u64), - ); - // As we loop, `cursor` will always be pointing to the next item - raw_args.next_os(&mut target_cursor); - - // TODO: Multicall support - if !cmd.is_no_binary_name_set() { - raw_args.next_os(&mut cursor); - } - - let mut current_cmd = &*cmd; - let mut pos_index = 1; - let mut is_escaped = false; - while let Some(arg) = raw_args.next(&mut cursor) { - if cursor == target_cursor { - return complete_arg(&arg, current_cmd, current_dir, pos_index, is_escaped); - } - - debug!("complete::next: Begin parsing '{:?}'", arg.to_value_os(),); - - if let Ok(value) = arg.to_value() { - if let Some(next_cmd) = current_cmd.find_subcommand(value) { - current_cmd = next_cmd; - pos_index = 0; - continue; - } - } - - if is_escaped { - pos_index += 1; - } else if arg.is_escape() { - is_escaped = true; - } else if let Some(_long) = arg.to_long() { - } else if let Some(_short) = arg.to_short() { - } else { - pos_index += 1; - } - } - - Err(std::io::Error::new( - std::io::ErrorKind::Other, - "No completion generated", - )) - } - - fn complete_arg( - arg: &clap_lex::ParsedArg<'_>, - cmd: &clap::Command, - current_dir: Option<&std::path::Path>, - pos_index: usize, - is_escaped: bool, - ) -> Result<Vec<std::ffi::OsString>, std::io::Error> { - debug!( - "complete_arg: arg={:?}, cmd={:?}, current_dir={:?}, pos_index={}, is_escaped={}", - arg, - cmd.get_name(), - current_dir, - pos_index, - is_escaped - ); - let mut completions = Vec::new(); - - if !is_escaped { - if let Some((flag, value)) = arg.to_long() { - if let Ok(flag) = flag { - if let Some(value) = value { - if let Some(arg) = cmd.get_arguments().find(|a| a.get_long() == Some(flag)) - { - completions.extend( - complete_arg_value(value.to_str().ok_or(value), arg, current_dir) - .into_iter() - .map(|os| { - // HACK: Need better `OsStr` manipulation - format!("--{}={}", flag, os.to_string_lossy()).into() - }), - ) - } - } else { - completions.extend( - crate::generator::utils::longs_and_visible_aliases(cmd) - .into_iter() - .filter_map(|f| { - f.starts_with(flag).then(|| format!("--{f}").into()) - }), - ); - } - } - } else if arg.is_escape() || arg.is_stdio() || arg.is_empty() { - // HACK: Assuming knowledge of is_escape / is_stdio - completions.extend( - crate::generator::utils::longs_and_visible_aliases(cmd) - .into_iter() - .map(|f| format!("--{f}").into()), - ); - } - - if arg.is_empty() || arg.is_stdio() || arg.is_short() { - // HACK: Assuming knowledge of is_stdio - completions.extend( - crate::generator::utils::shorts_and_visible_aliases(cmd) - .into_iter() - // HACK: Need better `OsStr` manipulation - .map(|f| format!("{}{}", arg.to_value_os().to_string_lossy(), f).into()), - ); - } - } - - if let Some(positional) = cmd - .get_positionals() - .find(|p| p.get_index() == Some(pos_index)) - { - completions.extend(complete_arg_value(arg.to_value(), positional, current_dir)); - } - - if let Ok(value) = arg.to_value() { - completions.extend(complete_subcommand(value, cmd)); - } - - Ok(completions) - } - - fn complete_arg_value( - value: Result<&str, &OsStr>, - arg: &clap::Arg, - current_dir: Option<&std::path::Path>, - ) -> Vec<OsString> { - let mut values = Vec::new(); - debug!("complete_arg_value: arg={arg:?}, value={value:?}"); - - if let Some(possible_values) = crate::generator::utils::possible_values(arg) { - if let Ok(value) = value { - values.extend(possible_values.into_iter().filter_map(|p| { - let name = p.get_name(); - name.starts_with(value).then(|| name.into()) - })); - } - } else { - let value_os = match value { - Ok(value) => OsStr::new(value), - Err(value_os) => value_os, - }; - match arg.get_value_hint() { - clap::ValueHint::Other => { - // Should not complete - } - clap::ValueHint::Unknown | clap::ValueHint::AnyPath => { - values.extend(complete_path(value_os, current_dir, |_| true)); - } - clap::ValueHint::FilePath => { - values.extend(complete_path(value_os, current_dir, |p| p.is_file())); - } - clap::ValueHint::DirPath => { - values.extend(complete_path(value_os, current_dir, |p| p.is_dir())); - } - clap::ValueHint::ExecutablePath => { - use is_executable::IsExecutable; - values.extend(complete_path(value_os, current_dir, |p| p.is_executable())); - } - clap::ValueHint::CommandName - | clap::ValueHint::CommandString - | clap::ValueHint::CommandWithArguments - | clap::ValueHint::Username - | clap::ValueHint::Hostname - | clap::ValueHint::Url - | clap::ValueHint::EmailAddress => { - // No completion implementation - } - _ => { - // Safe-ish fallback - values.extend(complete_path(value_os, current_dir, |_| true)); - } - } - values.sort(); - } - - values - } - - fn complete_path( - value_os: &OsStr, - current_dir: Option<&std::path::Path>, - is_wanted: impl Fn(&std::path::Path) -> bool, - ) -> Vec<OsString> { - let mut completions = Vec::new(); - - let current_dir = match current_dir { - Some(current_dir) => current_dir, - None => { - // Can't complete without a `current_dir` - return Vec::new(); - } - }; - let (existing, prefix) = value_os - .split_once("\\") - .unwrap_or((OsStr::new(""), value_os)); - let root = current_dir.join(existing); - debug!("complete_path: root={root:?}, prefix={prefix:?}"); - let prefix = prefix.to_string_lossy(); - - for entry in std::fs::read_dir(&root) - .ok() - .into_iter() - .flatten() - .filter_map(Result::ok) - { - let raw_file_name = OsString::from(entry.file_name()); - if !raw_file_name.starts_with(&prefix) { - continue; - } - - if entry.metadata().map(|m| m.is_dir()).unwrap_or(false) { - let path = entry.path(); - let mut suggestion = pathdiff::diff_paths(&path, current_dir).unwrap_or(path); - suggestion.push(""); // Ensure trailing `/` - completions.push(suggestion.as_os_str().to_owned()); - } else { - let path = entry.path(); - if is_wanted(&path) { - let suggestion = pathdiff::diff_paths(&path, current_dir).unwrap_or(path); - completions.push(suggestion.as_os_str().to_owned()); - } - } - } - - completions - } - - fn complete_subcommand(value: &str, cmd: &clap::Command) -> Vec<OsString> { - debug!( - "complete_subcommand: cmd={:?}, value={:?}", - cmd.get_name(), - value - ); - - let mut scs = crate::generator::utils::all_subcommands(cmd) - .into_iter() - .filter(|x| x.0.starts_with(value)) - .map(|x| OsString::from(&x.0)) - .collect::<Vec<_>>(); - scs.sort(); - scs.dedup(); - scs - } -} diff --git a/vendor/clap_complete/src/dynamic/completer.rs b/vendor/clap_complete/src/dynamic/completer.rs new file mode 100644 index 000000000..3813e910a --- /dev/null +++ b/vendor/clap_complete/src/dynamic/completer.rs @@ -0,0 +1,341 @@ +use std::ffi::OsStr; +use std::ffi::OsString; + +use clap::builder::StyledStr; +use clap_lex::OsStrExt as _; + +/// Shell-specific completions +pub trait Completer { + /// The recommended file name for the registration code + fn file_name(&self, name: &str) -> String; + /// Register for completions + fn write_registration( + &self, + name: &str, + bin: &str, + completer: &str, + buf: &mut dyn std::io::Write, + ) -> Result<(), std::io::Error>; + /// Complete the command + fn write_complete( + &self, + cmd: &mut clap::Command, + args: Vec<std::ffi::OsString>, + current_dir: Option<&std::path::Path>, + buf: &mut dyn std::io::Write, + ) -> Result<(), std::io::Error>; +} + +/// Complete the command specified +pub fn complete( + cmd: &mut clap::Command, + args: Vec<std::ffi::OsString>, + arg_index: usize, + current_dir: Option<&std::path::Path>, +) -> Result<Vec<(std::ffi::OsString, Option<StyledStr>)>, std::io::Error> { + cmd.build(); + + let raw_args = clap_lex::RawArgs::new(args.into_iter()); + let mut cursor = raw_args.cursor(); + let mut target_cursor = raw_args.cursor(); + raw_args.seek( + &mut target_cursor, + clap_lex::SeekFrom::Start(arg_index as u64), + ); + // As we loop, `cursor` will always be pointing to the next item + raw_args.next_os(&mut target_cursor); + + // TODO: Multicall support + if !cmd.is_no_binary_name_set() { + raw_args.next_os(&mut cursor); + } + + let mut current_cmd = &*cmd; + let mut pos_index = 1; + let mut is_escaped = false; + while let Some(arg) = raw_args.next(&mut cursor) { + if cursor == target_cursor { + return complete_arg(&arg, current_cmd, current_dir, pos_index, is_escaped); + } + + debug!("complete::next: Begin parsing '{:?}'", arg.to_value_os(),); + + if let Ok(value) = arg.to_value() { + if let Some(next_cmd) = current_cmd.find_subcommand(value) { + current_cmd = next_cmd; + pos_index = 1; + continue; + } + } + + if is_escaped { + pos_index += 1; + } else if arg.is_escape() { + is_escaped = true; + } else if let Some(_long) = arg.to_long() { + } else if let Some(_short) = arg.to_short() { + } else { + pos_index += 1; + } + } + + Err(std::io::Error::new( + std::io::ErrorKind::Other, + "no completion generated", + )) +} + +fn complete_arg( + arg: &clap_lex::ParsedArg<'_>, + cmd: &clap::Command, + current_dir: Option<&std::path::Path>, + pos_index: usize, + is_escaped: bool, +) -> Result<Vec<(std::ffi::OsString, Option<StyledStr>)>, std::io::Error> { + debug!( + "complete_arg: arg={:?}, cmd={:?}, current_dir={:?}, pos_index={}, is_escaped={}", + arg, + cmd.get_name(), + current_dir, + pos_index, + is_escaped + ); + let mut completions = Vec::new(); + + if !is_escaped { + if let Some((flag, value)) = arg.to_long() { + if let Ok(flag) = flag { + if let Some(value) = value { + if let Some(arg) = cmd.get_arguments().find(|a| a.get_long() == Some(flag)) { + completions.extend( + complete_arg_value(value.to_str().ok_or(value), arg, current_dir) + .into_iter() + .map(|(os, help)| { + // HACK: Need better `OsStr` manipulation + (format!("--{}={}", flag, os.to_string_lossy()).into(), help) + }), + ) + } + } else { + completions.extend(longs_and_visible_aliases(cmd).into_iter().filter_map( + |(f, help)| f.starts_with(flag).then(|| (format!("--{f}").into(), help)), + )); + } + } + } else if arg.is_escape() || arg.is_stdio() || arg.is_empty() { + // HACK: Assuming knowledge of is_escape / is_stdio + completions.extend( + longs_and_visible_aliases(cmd) + .into_iter() + .map(|(f, help)| (format!("--{f}").into(), help)), + ); + } + + if arg.is_empty() || arg.is_stdio() || arg.is_short() { + let dash_or_arg = if arg.is_empty() { + "-".into() + } else { + arg.to_value_os().to_string_lossy() + }; + // HACK: Assuming knowledge of is_stdio + completions.extend( + shorts_and_visible_aliases(cmd) + .into_iter() + // HACK: Need better `OsStr` manipulation + .map(|(f, help)| (format!("{}{}", dash_or_arg, f).into(), help)), + ); + } + } + + if let Some(positional) = cmd + .get_positionals() + .find(|p| p.get_index() == Some(pos_index)) + { + completions.extend(complete_arg_value(arg.to_value(), positional, current_dir)); + } + + if let Ok(value) = arg.to_value() { + completions.extend(complete_subcommand(value, cmd)); + } + + Ok(completions) +} + +fn complete_arg_value( + value: Result<&str, &OsStr>, + arg: &clap::Arg, + current_dir: Option<&std::path::Path>, +) -> Vec<(OsString, Option<StyledStr>)> { + let mut values = Vec::new(); + debug!("complete_arg_value: arg={arg:?}, value={value:?}"); + + if let Some(possible_values) = possible_values(arg) { + if let Ok(value) = value { + values.extend(possible_values.into_iter().filter_map(|p| { + let name = p.get_name(); + name.starts_with(value) + .then(|| (name.into(), p.get_help().cloned())) + })); + } + } else { + let value_os = match value { + Ok(value) => OsStr::new(value), + Err(value_os) => value_os, + }; + match arg.get_value_hint() { + clap::ValueHint::Other => { + // Should not complete + } + clap::ValueHint::Unknown | clap::ValueHint::AnyPath => { + values.extend(complete_path(value_os, current_dir, |_| true)); + } + clap::ValueHint::FilePath => { + values.extend(complete_path(value_os, current_dir, |p| p.is_file())); + } + clap::ValueHint::DirPath => { + values.extend(complete_path(value_os, current_dir, |p| p.is_dir())); + } + clap::ValueHint::ExecutablePath => { + use is_executable::IsExecutable; + values.extend(complete_path(value_os, current_dir, |p| p.is_executable())); + } + clap::ValueHint::CommandName + | clap::ValueHint::CommandString + | clap::ValueHint::CommandWithArguments + | clap::ValueHint::Username + | clap::ValueHint::Hostname + | clap::ValueHint::Url + | clap::ValueHint::EmailAddress => { + // No completion implementation + } + _ => { + // Safe-ish fallback + values.extend(complete_path(value_os, current_dir, |_| true)); + } + } + values.sort(); + } + + values +} + +fn complete_path( + value_os: &OsStr, + current_dir: Option<&std::path::Path>, + is_wanted: impl Fn(&std::path::Path) -> bool, +) -> Vec<(OsString, Option<StyledStr>)> { + let mut completions = Vec::new(); + + let current_dir = match current_dir { + Some(current_dir) => current_dir, + None => { + // Can't complete without a `current_dir` + return Vec::new(); + } + }; + let (existing, prefix) = value_os + .split_once("\\") + .unwrap_or((OsStr::new(""), value_os)); + let root = current_dir.join(existing); + debug!("complete_path: root={root:?}, prefix={prefix:?}"); + let prefix = prefix.to_string_lossy(); + + for entry in std::fs::read_dir(&root) + .ok() + .into_iter() + .flatten() + .filter_map(Result::ok) + { + let raw_file_name = entry.file_name(); + if !raw_file_name.starts_with(&prefix) { + continue; + } + + if entry.metadata().map(|m| m.is_dir()).unwrap_or(false) { + let path = entry.path(); + let mut suggestion = pathdiff::diff_paths(&path, current_dir).unwrap_or(path); + suggestion.push(""); // Ensure trailing `/` + completions.push((suggestion.as_os_str().to_owned(), None)); + } else { + let path = entry.path(); + if is_wanted(&path) { + let suggestion = pathdiff::diff_paths(&path, current_dir).unwrap_or(path); + completions.push((suggestion.as_os_str().to_owned(), None)); + } + } + } + + completions +} + +fn complete_subcommand(value: &str, cmd: &clap::Command) -> Vec<(OsString, Option<StyledStr>)> { + debug!( + "complete_subcommand: cmd={:?}, value={:?}", + cmd.get_name(), + value + ); + + let mut scs = subcommands(cmd) + .into_iter() + .filter(|x| x.0.starts_with(value)) + .map(|x| (OsString::from(&x.0), x.1)) + .collect::<Vec<_>>(); + scs.sort(); + scs.dedup(); + scs +} + +/// Gets all the long options, their visible aliases and flags of a [`clap::Command`]. +/// Includes `help` and `version` depending on the [`clap::Command`] settings. +fn longs_and_visible_aliases(p: &clap::Command) -> Vec<(String, Option<StyledStr>)> { + debug!("longs: name={}", p.get_name()); + + p.get_arguments() + .filter_map(|a| { + a.get_long_and_visible_aliases().map(|longs| { + longs + .into_iter() + .map(|s| (s.to_string(), a.get_help().cloned())) + }) + }) + .flatten() + .collect() +} + +/// Gets all the short options, their visible aliases and flags of a [`clap::Command`]. +/// Includes `h` and `V` depending on the [`clap::Command`] settings. +fn shorts_and_visible_aliases(p: &clap::Command) -> Vec<(char, Option<StyledStr>)> { + debug!("shorts: name={}", p.get_name()); + + p.get_arguments() + .filter_map(|a| { + a.get_short_and_visible_aliases() + .map(|shorts| shorts.into_iter().map(|s| (s, a.get_help().cloned()))) + }) + .flatten() + .collect() +} + +/// Get the possible values for completion +fn possible_values(a: &clap::Arg) -> Option<Vec<clap::builder::PossibleValue>> { + if !a.get_num_args().expect("built").takes_values() { + None + } else { + a.get_value_parser() + .possible_values() + .map(|pvs| pvs.collect()) + } +} + +/// Gets subcommands of [`clap::Command`] in the form of `("name", "bin_name")`. +/// +/// Subcommand `rustup toolchain install` would be converted to +/// `("install", "rustup toolchain install")`. +fn subcommands(p: &clap::Command) -> Vec<(String, Option<StyledStr>)> { + debug!("subcommands: name={}", p.get_name()); + debug!("subcommands: Has subcommands...{:?}", p.has_subcommands()); + + p.get_subcommands() + .map(|sc| (sc.get_name().to_string(), sc.get_about().cloned())) + .collect() +} diff --git a/vendor/clap_complete/src/dynamic/mod.rs b/vendor/clap_complete/src/dynamic/mod.rs new file mode 100644 index 000000000..f7c985704 --- /dev/null +++ b/vendor/clap_complete/src/dynamic/mod.rs @@ -0,0 +1,7 @@ +//! Complete commands within shells + +mod completer; + +pub mod shells; + +pub use completer::*; diff --git a/vendor/clap_complete/src/dynamic/shells/bash.rs b/vendor/clap_complete/src/dynamic/shells/bash.rs new file mode 100644 index 000000000..43c128e5b --- /dev/null +++ b/vendor/clap_complete/src/dynamic/shells/bash.rs @@ -0,0 +1,121 @@ +use unicode_xid::UnicodeXID as _; + +/// Bash completions +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +pub struct Bash; + +impl crate::dynamic::Completer for Bash { + fn file_name(&self, name: &str) -> String { + format!("{name}.bash") + } + fn write_registration( + &self, + name: &str, + bin: &str, + completer: &str, + buf: &mut dyn std::io::Write, + ) -> Result<(), std::io::Error> { + let escaped_name = name.replace('-', "_"); + debug_assert!( + escaped_name.chars().all(|c| c.is_xid_continue()), + "`name` must be an identifier, got `{escaped_name}`" + ); + let mut upper_name = escaped_name.clone(); + upper_name.make_ascii_uppercase(); + + let completer = shlex::quote(completer); + + let script = r#" +_clap_complete_NAME() { + export IFS=$'\013' + export _CLAP_COMPLETE_INDEX=${COMP_CWORD} + export _CLAP_COMPLETE_COMP_TYPE=${COMP_TYPE} + if compopt +o nospace 2> /dev/null; then + export _CLAP_COMPLETE_SPACE=false + else + export _CLAP_COMPLETE_SPACE=true + fi + COMPREPLY=( $("COMPLETER" complete --shell bash -- "${COMP_WORDS[@]}") ) + if [[ $? != 0 ]]; then + unset COMPREPLY + elif [[ $SUPPRESS_SPACE == 1 ]] && [[ "${COMPREPLY-}" =~ [=/:]$ ]]; then + compopt -o nospace + fi +} +complete -o nospace -o bashdefault -F _clap_complete_NAME BIN +"# + .replace("NAME", &escaped_name) + .replace("BIN", bin) + .replace("COMPLETER", &completer) + .replace("UPPER", &upper_name); + + writeln!(buf, "{script}")?; + Ok(()) + } + fn write_complete( + &self, + cmd: &mut clap::Command, + args: Vec<std::ffi::OsString>, + current_dir: Option<&std::path::Path>, + buf: &mut dyn std::io::Write, + ) -> Result<(), std::io::Error> { + let index: usize = std::env::var("_CLAP_COMPLETE_INDEX") + .ok() + .and_then(|i| i.parse().ok()) + .unwrap_or_default(); + let _comp_type: CompType = std::env::var("_CLAP_COMPLETE_COMP_TYPE") + .ok() + .and_then(|i| i.parse().ok()) + .unwrap_or_default(); + let _space: Option<bool> = std::env::var("_CLAP_COMPLETE_SPACE") + .ok() + .and_then(|i| i.parse().ok()); + let ifs: Option<String> = std::env::var("IFS").ok().and_then(|i| i.parse().ok()); + let completions = crate::dynamic::complete(cmd, args, index, current_dir)?; + + for (i, (completion, _)) in completions.iter().enumerate() { + if i != 0 { + write!(buf, "{}", ifs.as_deref().unwrap_or("\n"))?; + } + write!(buf, "{}", completion.to_string_lossy())?; + } + Ok(()) + } +} + +/// Type of completion attempted that caused a completion function to be called +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[non_exhaustive] +enum CompType { + /// Normal completion + Normal, + /// List completions after successive tabs + Successive, + /// List alternatives on partial word completion + Alternatives, + /// List completions if the word is not unmodified + Unmodified, + /// Menu completion + Menu, +} + +impl std::str::FromStr for CompType { + type Err = String; + + fn from_str(s: &str) -> Result<Self, Self::Err> { + match s { + "9" => Ok(Self::Normal), + "63" => Ok(Self::Successive), + "33" => Ok(Self::Alternatives), + "64" => Ok(Self::Unmodified), + "37" => Ok(Self::Menu), + _ => Err(format!("unsupported COMP_TYPE `{}`", s)), + } + } +} + +impl Default for CompType { + fn default() -> Self { + Self::Normal + } +} diff --git a/vendor/clap_complete/src/dynamic/shells/fish.rs b/vendor/clap_complete/src/dynamic/shells/fish.rs new file mode 100644 index 000000000..9d7e8c684 --- /dev/null +++ b/vendor/clap_complete/src/dynamic/shells/fish.rs @@ -0,0 +1,46 @@ +/// Fish completions +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +pub struct Fish; + +impl crate::dynamic::Completer for Fish { + fn file_name(&self, name: &str) -> String { + format!("{name}.fish") + } + fn write_registration( + &self, + _name: &str, + bin: &str, + completer: &str, + buf: &mut dyn std::io::Write, + ) -> Result<(), std::io::Error> { + let bin = shlex::quote(bin); + let completer = shlex::quote(completer); + writeln!( + buf, + r#"complete -x -c {bin} -a "("'{completer}'" complete --shell fish -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))""# + ) + } + fn write_complete( + &self, + cmd: &mut clap::Command, + args: Vec<std::ffi::OsString>, + current_dir: Option<&std::path::Path>, + buf: &mut dyn std::io::Write, + ) -> Result<(), std::io::Error> { + let index = args.len() - 1; + let completions = crate::dynamic::complete(cmd, args, index, current_dir)?; + + for (completion, help) in completions { + write!(buf, "{}", completion.to_string_lossy())?; + if let Some(help) = help { + write!( + buf, + "\t{}", + help.to_string().lines().next().unwrap_or_default() + )?; + } + writeln!(buf)?; + } + Ok(()) + } +} diff --git a/vendor/clap_complete/src/dynamic/shells/mod.rs b/vendor/clap_complete/src/dynamic/shells/mod.rs new file mode 100644 index 000000000..54d23a3d4 --- /dev/null +++ b/vendor/clap_complete/src/dynamic/shells/mod.rs @@ -0,0 +1,82 @@ +//! Shell support + +mod bash; +mod fish; +mod shell; + +pub use bash::*; +pub use fish::*; +pub use shell::*; + +use std::ffi::OsString; +use std::io::Write as _; + +use crate::dynamic::Completer as _; + +#[derive(clap::Subcommand)] +#[allow(missing_docs)] +#[derive(Clone, Debug)] +pub enum CompleteCommand { + /// Register shell completions for this program + #[command(hide = true)] + Complete(CompleteArgs), +} + +#[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)] +pub struct CompleteArgs { + /// Specify shell to complete for + #[arg(long)] + shell: Shell, + + /// Path to write completion-registration to + #[arg(long, required = true)] + register: Option<std::path::PathBuf>, + + #[arg(raw = true, hide_short_help = true, group = "complete")] + comp_words: Vec<OsString>, +} + +impl CompleteCommand { + /// Process the completion request + pub fn complete(&self, cmd: &mut clap::Command) -> std::convert::Infallible { + self.try_complete(cmd).unwrap_or_else(|e| e.exit()); + std::process::exit(0) + } + + /// Process the completion request + pub fn try_complete(&self, cmd: &mut clap::Command) -> clap::error::Result<()> { + debug!("CompleteCommand::try_complete: {self:?}"); + let CompleteCommand::Complete(args) = self; + if let Some(out_path) = args.register.as_deref() { + let mut buf = Vec::new(); + let name = cmd.get_name(); + let bin = cmd.get_bin_name().unwrap_or_else(|| cmd.get_name()); + args.shell.write_registration(name, bin, bin, &mut buf)?; + if out_path == std::path::Path::new("-") { + std::io::stdout().write_all(&buf)?; + } else if out_path.is_dir() { + let out_path = out_path.join(args.shell.file_name(name)); + std::fs::write(out_path, buf)?; + } else { + std::fs::write(out_path, buf)?; + } + } else { + let current_dir = std::env::current_dir().ok(); + + let mut buf = Vec::new(); + args.shell.write_complete( + cmd, + args.comp_words.clone(), + current_dir.as_deref(), + &mut buf, + )?; + std::io::stdout().write_all(&buf)?; + } + + Ok(()) + } +} diff --git a/vendor/clap_complete/src/dynamic/shells/shell.rs b/vendor/clap_complete/src/dynamic/shells/shell.rs new file mode 100644 index 000000000..a9f48cee9 --- /dev/null +++ b/vendor/clap_complete/src/dynamic/shells/shell.rs @@ -0,0 +1,85 @@ +use std::fmt::Display; +use std::str::FromStr; + +use clap::builder::PossibleValue; +use clap::ValueEnum; + +/// Shell with auto-generated completion script available. +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +#[non_exhaustive] +pub enum Shell { + /// Bourne Again SHell (bash) + Bash, + /// Friendly Interactive SHell (fish) + Fish, +} + +impl Display for Shell { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.to_possible_value() + .expect("no values are skipped") + .get_name() + .fmt(f) + } +} + +impl FromStr for Shell { + type Err = String; + + fn from_str(s: &str) -> Result<Self, Self::Err> { + for variant in Self::value_variants() { + if variant.to_possible_value().unwrap().matches(s, false) { + return Ok(*variant); + } + } + Err(format!("invalid variant: {s}")) + } +} + +// Hand-rolled so it can work even when `derive` feature is disabled +impl ValueEnum for Shell { + fn value_variants<'a>() -> &'a [Self] { + &[Shell::Bash, Shell::Fish] + } + + fn to_possible_value<'a>(&self) -> Option<PossibleValue> { + Some(match self { + Shell::Bash => PossibleValue::new("bash"), + Shell::Fish => PossibleValue::new("fish"), + }) + } +} + +impl Shell { + fn completer(&self) -> &dyn crate::dynamic::Completer { + match self { + Self::Bash => &super::Bash, + Self::Fish => &super::Fish, + } + } +} + +impl crate::dynamic::Completer for Shell { + fn file_name(&self, name: &str) -> String { + self.completer().file_name(name) + } + fn write_registration( + &self, + name: &str, + bin: &str, + completer: &str, + buf: &mut dyn std::io::Write, + ) -> Result<(), std::io::Error> { + self.completer() + .write_registration(name, bin, completer, buf) + } + fn write_complete( + &self, + cmd: &mut clap::Command, + args: Vec<std::ffi::OsString>, + current_dir: Option<&std::path::Path>, + buf: &mut dyn std::io::Write, + ) -> Result<(), std::io::Error> { + self.completer().write_complete(cmd, args, current_dir, buf) + } +} diff --git a/vendor/clap_complete/src/shells/bash.rs b/vendor/clap_complete/src/shells/bash.rs index 60e6b346c..2a97e1de2 100644 --- a/vendor/clap_complete/src/shells/bash.rs +++ b/vendor/clap_complete/src/shells/bash.rs @@ -58,7 +58,7 @@ impl Generator for Bash { esac }} -complete -F _{name} -o bashdefault -o default {name} +complete -F _{name} -o nosort -o bashdefault -o default {name} ", name = bin_name, cmd = bin_name.replace('-', "__"), diff --git a/vendor/clap_complete/src/shells/fish.rs b/vendor/clap_complete/src/shells/fish.rs index 5a069d35b..7dae5b6d6 100644 --- a/vendor/clap_complete/src/shells/fish.rs +++ b/vendor/clap_complete/src/shells/fish.rs @@ -168,10 +168,12 @@ fn value_completion(option: &Arg) -> String { .filter_map(|value| if value.is_hide_set() { None } else { + // The help text after \t is wrapped in '' to make sure that the it is taken literally + // and there is no command substitution or variable expansion resulting in unexpected errors Some(format!( - "{}\t{}", + "{}\t'{}'", escape_string(value.get_name(), true).as_str(), - escape_string(&value.get_help().unwrap_or_default().to_string(), true) + escape_string(&value.get_help().unwrap_or_default().to_string(), false) )) }) .collect::<Vec<_>>() diff --git a/vendor/clap_complete/src/shells/powershell.rs b/vendor/clap_complete/src/shells/powershell.rs index 417facf70..6b09b2e3a 100644 --- a/vendor/clap_complete/src/shells/powershell.rs +++ b/vendor/clap_complete/src/shells/powershell.rs @@ -124,7 +124,9 @@ fn generate_aliases(completions: &mut String, preamble: &String, arg: &Arg) { for alias in aliases { let _ = write!( completions, - "{preamble}'-{alias}', '{alias}', [CompletionResultType]::ParameterName, '{tooltip}')" + "{preamble}'-{alias}', '{alias}{}', [CompletionResultType]::ParameterName, '{tooltip}')", + // make PowerShell realize there is a difference between `-s` and `-S` + if alias.is_uppercase() { " " } else { "" }, ); } } |