-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Since other people are actually on zsh!
Signed-off-by: itowlson <[email protected]>
- Loading branch information
Showing
3 changed files
with
28 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use anyhow::Result; | ||
use clap::Parser; | ||
|
||
/// Generate shell completions. | ||
#[derive(Parser, Debug)] | ||
#[clap(about = "Generate completions")] | ||
pub struct GenerateCompletionsCommand { | ||
#[clap(value_parser = clap::value_parser!(clap_complete::Shell))] | ||
pub shell: clap_complete::Shell, | ||
} | ||
|
||
impl GenerateCompletionsCommand { | ||
pub async fn run(&self, mut cmd: clap::Command<'_>) -> Result<()> { | ||
// let mut cmd: clap::Command = SpinApp::into_app(); | ||
print_completions(self.shell, &mut cmd); | ||
Ok(()) | ||
} | ||
} | ||
|
||
fn print_completions<G: clap_complete::Generator>(gen: G, cmd: &mut clap::Command) { | ||
clap_complete::generate(gen, cmd, cmd.get_name().to_string(), &mut std::io::stdout()) | ||
} |