-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor man and completion with clap derive api
- Loading branch information
Showing
22 changed files
with
270 additions
and
233 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
use clap::{value_parser, Parser}; | ||
use clap_complete::Shell; | ||
|
||
/// Print completion script for the given shell to stdout | ||
#[derive(Debug, Parser)] | ||
pub struct Generate { | ||
/// Shell that completion script should be generated for | ||
#[arg(value_parser = value_parser!(Shell))] | ||
pub shell: Shell, | ||
} |
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,18 @@ | ||
use anyhow::Result; | ||
use clap::Command; | ||
use clap_complete::Shell; | ||
use std::io::stdout; | ||
|
||
use crate::printer::Printer; | ||
|
||
pub fn generate(printer: &mut impl Printer, mut cmd: Command, shell: Shell) -> Result<()> { | ||
let name = cmd.get_name().to_string(); | ||
|
||
clap_complete::generate(shell, &mut cmd, name, &mut stdout()); | ||
|
||
printer.print(format!( | ||
"Shell script successfully generated for shell {shell}!" | ||
))?; | ||
|
||
Ok(()) | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,8 +1,2 @@ | ||
//! Module related to shell completion. | ||
//! | ||
//! This module allows users to generate autocompletion scripts for | ||
//! their shells. You can see the list of available shells directly on | ||
//! the clap's [docs.rs](https://docs.rs/clap/2.33.3/clap/enum.Shell.html). | ||
pub mod args; | ||
pub mod handlers; | ||
pub mod command; | ||
pub mod handler; |
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
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
Oops, something went wrong.