Skip to content

Commit

Permalink
feat: add wrestic completions (writes to stdout)
Browse files Browse the repository at this point in the history
  • Loading branch information
tippfehlr committed Jan 19, 2024
1 parent 03f7e60 commit 8e866bc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ enum Commands {
#[clap(short_flag = 'c', allow_hyphen_values = true)]
#[command(arg_required_else_help = true)]
Custom { args: Vec<String> },
/// Generate tab-completion scripts for your shell
Completions { shell: Shell },
}

fn handle_completions(cli: &Cli) -> Result<()> {
Expand Down Expand Up @@ -110,6 +112,14 @@ fn handle_commands(cli: &Cli) -> Result<()> {
Some(Commands::Custom { args }) => {
custom(args)?;
}
Some(Commands::Completions { shell }) => {
clap_complete::generate(
*shell,
&mut Cli::command(),
"wrestic",
&mut std::io::stdout().lock(),
);
}
None => {
selector()?;
}
Expand Down

0 comments on commit 8e866bc

Please sign in to comment.