clean up shell completion
This commit is contained in:
@@ -2,3 +2,4 @@ flamegraph.svg
|
|||||||
perf.data
|
perf.data
|
||||||
perf.data.old
|
perf.data.old
|
||||||
**/target
|
**/target
|
||||||
|
_pacdef
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ use std::path::Path;
|
|||||||
|
|
||||||
use anyhow::{anyhow, bail, ensure, Context, Result};
|
use anyhow::{anyhow, bail, ensure, Context, Result};
|
||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use clap_complete::{generate, shells::Zsh};
|
|
||||||
use const_format::formatcp;
|
use const_format::formatcp;
|
||||||
|
|
||||||
use crate::action::*;
|
use crate::action::*;
|
||||||
@@ -85,7 +84,7 @@ impl Pacdef {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Some((VERSION, _)) => Ok(self.show_version()),
|
Some((VERSION, _)) => Ok(self.show_version()),
|
||||||
Some((COMPLETION, _)) => Ok(self.generate_shell_completion()),
|
Some((COMPLETION, _)) => generate_shell_completion(),
|
||||||
|
|
||||||
Some((_, _)) => panic!("{ACTION_NOT_MATCHED}"),
|
Some((_, _)) => panic!("{ACTION_NOT_MATCHED}"),
|
||||||
None => unreachable!("{UNREACHABLE_ARM}"),
|
None => unreachable!("{UNREACHABLE_ARM}"),
|
||||||
@@ -316,16 +315,6 @@ impl Pacdef {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::unused_self)]
|
|
||||||
fn generate_shell_completion(&self) {
|
|
||||||
generate(
|
|
||||||
Zsh,
|
|
||||||
&mut crate::args::build_cli(),
|
|
||||||
"pacdef",
|
|
||||||
&mut std::io::stdout(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For the provided CLI arguments, get the path to each corresponding group file.
|
/// For the provided CLI arguments, get the path to each corresponding group file.
|
||||||
@@ -393,3 +382,15 @@ pub const fn get_version_string() -> &'static str {
|
|||||||
formatcp!("{VERSION} ({HASH})")
|
formatcp!("{VERSION} ({HASH})")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn generate_shell_completion() -> Result<()> {
|
||||||
|
let mut output = File::create("_pacdef")?;
|
||||||
|
clap_complete::generate(
|
||||||
|
clap_complete::Shell::Zsh,
|
||||||
|
&mut crate::args::build_cli(),
|
||||||
|
"pacdef",
|
||||||
|
&mut output,
|
||||||
|
);
|
||||||
|
println!("completion written to _pacdef");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user