File tree 1 file changed +26
-0
lines changed
clap_complete/src/generator
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,32 @@ pub trait Generator {
162
162
///
163
163
/// **NOTE:** Please look at the individual [shells][crate::shells]
164
164
/// to see the name of the files generated.
165
+ ///
166
+ /// Using [`ValueEnum::value_variants()`][clap::ValueEnum::value_variants] you can easily loop over
167
+ /// all the supported shell variants to generate all the completions at once too.
168
+ ///
169
+ /// ```ignore
170
+ /// use clap::ValueEnum;
171
+ /// use clap_complete::{generate_to, Shell};
172
+ /// use std::env;
173
+ /// use std::io::Error;
174
+ ///
175
+ /// include!("src/cli.rs");
176
+ ///
177
+ /// fn main() -> Result<(), Error> {
178
+ /// let outdir = match env::var_os("OUT_DIR") {
179
+ /// None => return Ok(()),
180
+ /// Some(outdir) => outdir,
181
+ /// };
182
+ ///
183
+ /// let mut cmd = build_cli();
184
+ /// for &shell in Shell::value_variants() {
185
+ /// generate_to(shell, &mut cmd, "myapp", outdir)?;
186
+ /// }
187
+ ///
188
+ /// Ok(())
189
+ /// }
190
+ /// ```
165
191
pub fn generate_to < G , S , T > (
166
192
gen : G ,
167
193
cmd : & mut Command ,
You can’t perform that action at this time.
0 commit comments