Skip to content

Commit 7fc2de1

Browse files
authored
Implement shell completions for wpush command
Added support for shell completions in wpush command.
1 parent f161432 commit 7fc2de1

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/wpush.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use clap::Parser;
1+
use clap::{CommandFactory, Parser};
2+
use clap_complete::{generate, Shell};
23

34
#[derive(Parser)]
45
#[command(
@@ -66,6 +67,8 @@ struct Args {
6667
/// Preview the actions without actually cloning or copying
6768
#[arg(short = 'n', long = "dry-run")]
6869
dry_run: bool,
70+
#[arg(long, hide = true, exclusive = true)]
71+
completions: Option<Shell>,
6972
}
7073

7174
#[cfg(target_os = "windows")]
@@ -296,6 +299,13 @@ mod windows_impl {
296299

297300
let args = Args::parse();
298301

302+
if let Some(shell) = args.completions {
303+
let mut cmd = Args::command();
304+
let name = cmd.get_name().to_string();
305+
generate(shell, &mut cmd, name, &mut io::stdout());
306+
return Ok(());
307+
}
308+
299309
validate_repo_url(&args.repo)?;
300310
validate_distro(&args.distro)?;
301311
if let Some(ref u) = args.user {

0 commit comments

Comments
 (0)