summaryrefslogtreecommitdiffstats
path: root/vendor/clap_complete/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/clap_complete/src
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/clap_complete/src')
-rw-r--r--vendor/clap_complete/src/generator/mod.rs26
-rw-r--r--vendor/clap_complete/src/shells/zsh.rs4
2 files changed, 29 insertions, 1 deletions
diff --git a/vendor/clap_complete/src/generator/mod.rs b/vendor/clap_complete/src/generator/mod.rs
index c6e5c5ec8..a371f68a6 100644
--- a/vendor/clap_complete/src/generator/mod.rs
+++ b/vendor/clap_complete/src/generator/mod.rs
@@ -162,6 +162,32 @@ pub trait Generator {
///
/// **NOTE:** Please look at the individual [shells][crate::shells]
/// to see the name of the files generated.
+///
+/// Using [`ValueEnum::value_variants()`][clap::ValueEnum::value_variants] you can easily loop over
+/// all the supported shell variants to generate all the completions at once too.
+///
+/// ```ignore
+/// use clap::ValueEnum;
+/// use clap_complete::{generate_to, Shell};
+/// use std::env;
+/// use std::io::Error;
+///
+/// include!("src/cli.rs");
+///
+/// fn main() -> Result<(), Error> {
+/// let outdir = match env::var_os("OUT_DIR") {
+/// None => return Ok(()),
+/// Some(outdir) => outdir,
+/// };
+///
+/// let mut cmd = build_cli();
+/// for &shell in Shell::value_variants() {
+/// generate_to(shell, &mut cmd, "myapp", outdir)?;
+/// }
+///
+/// Ok(())
+/// }
+/// ```
pub fn generate_to<G, S, T>(
gen: G,
cmd: &mut Command,
diff --git a/vendor/clap_complete/src/shells/zsh.rs b/vendor/clap_complete/src/shells/zsh.rs
index 71c586d8e..65d7af65b 100644
--- a/vendor/clap_complete/src/shells/zsh.rs
+++ b/vendor/clap_complete/src/shells/zsh.rs
@@ -624,7 +624,9 @@ fn write_positionals_of(p: &Command) -> String {
}
let cardinality_value;
- let cardinality = if is_multi_valued {
+ // If we have any subcommands, we'll emit a catch-all argument, so we shouldn't
+ // emit one here.
+ let cardinality = if is_multi_valued && !p.has_subcommands() {
match arg.get_value_terminator() {
Some(terminator) => {
cardinality_value = format!("*{}:", escape_value(terminator));