summaryrefslogtreecommitdiffstats
path: root/vendor/clap_complete/src/generator
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/clap_complete/src/generator
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/clap_complete/src/generator')
-rw-r--r--vendor/clap_complete/src/generator/mod.rs31
1 files changed, 13 insertions, 18 deletions
diff --git a/vendor/clap_complete/src/generator/mod.rs b/vendor/clap_complete/src/generator/mod.rs
index c025697ed..c6e5c5ec8 100644
--- a/vendor/clap_complete/src/generator/mod.rs
+++ b/vendor/clap_complete/src/generator/mod.rs
@@ -28,10 +28,10 @@ pub trait Generator {
/// pub struct Fish;
///
/// impl Generator for Fish {
- /// # fn generate(&self, cmd: &Command, buf: &mut dyn Write) {}
/// fn file_name(&self, name: &str) -> String {
- /// format!("{}.fish", name)
+ /// format!("{name}.fish")
/// }
+ /// # fn generate(&self, cmd: &Command, buf: &mut dyn Write) {}
/// }
/// ```
fn file_name(&self, name: &str) -> String;
@@ -55,12 +55,12 @@ pub trait Generator {
/// pub struct ClapDebug;
///
/// impl Generator for ClapDebug {
- /// fn generate(&self, cmd: &Command, buf: &mut dyn Write) {
- /// write!(buf, "{}", cmd).unwrap();
- /// }
/// # fn file_name(&self, name: &str) -> String {
- /// # name.into()
+ /// # name.into()
/// # }
+ /// fn generate(&self, cmd: &Command, buf: &mut dyn Write) {
+ /// write!(buf, "{cmd}").unwrap();
+ /// }
/// }
/// ```
fn generate(&self, cmd: &Command, buf: &mut dyn Write);
@@ -150,7 +150,7 @@ pub trait Generator {
/// outdir, // We need to specify where to write to
/// )?;
///
-/// println!("cargo:warning=completion file is generated: {:?}", path);
+/// println!("cargo:warning=completion file is generated: {path:?}");
///
/// Ok(())
/// }
@@ -164,7 +164,7 @@ pub trait Generator {
/// to see the name of the files generated.
pub fn generate_to<G, S, T>(
gen: G,
- cmd: &mut clap::Command,
+ cmd: &mut Command,
bin_name: S,
out_dir: T,
) -> Result<PathBuf, Error>
@@ -181,7 +181,7 @@ where
let path = out_dir.join(file_name);
let mut file = File::create(&path)?;
- _generate::<G, S>(gen, cmd, &mut file);
+ _generate::<G>(gen, cmd, &mut file);
Ok(path)
}
@@ -217,24 +217,19 @@ where
///
/// Usage:
///
-/// ```shell
+/// ```console
/// $ myapp generate-bash-completions > /usr/share/bash-completion/completions/myapp.bash
/// ```
-pub fn generate<G, S>(gen: G, cmd: &mut clap::Command, bin_name: S, buf: &mut dyn Write)
+pub fn generate<G, S>(gen: G, cmd: &mut Command, bin_name: S, buf: &mut dyn Write)
where
G: Generator,
S: Into<String>,
{
cmd.set_bin_name(bin_name);
- _generate::<G, S>(gen, cmd, buf)
+ _generate::<G>(gen, cmd, buf)
}
-fn _generate<G, S>(gen: G, cmd: &mut clap::Command, buf: &mut dyn Write)
-where
- G: Generator,
- S: Into<String>,
-{
+fn _generate<G: Generator>(gen: G, cmd: &mut Command, buf: &mut dyn Write) {
cmd.build();
-
gen.generate(cmd, buf)
}