From 0abd063e018ecb8851c3a816aa941dd04d594c9e Mon Sep 17 00:00:00 2001 From: Orhun Parmaksız Date: Sat, 11 Dec 2021 02:59:39 +0300 Subject: Support generating shell completions (#235) * Add gen-completions subcommand for generating shell completions * Update documentation about generating shell completions * Include the shell completions in release tarball --- src/command/mod.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/command') diff --git a/src/command/mod.rs b/src/command/mod.rs index dc1f01fb..d82ad13b 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -1,6 +1,7 @@ use std::path::PathBuf; use eyre::{Result, WrapErr}; +use structopt::clap::Shell; use structopt::StructOpt; use atuin_client::database::Sqlite; @@ -92,6 +93,15 @@ pub enum AtuinCmd { #[structopt(about = "print the encryption key for transfer to another machine")] Key, + + #[structopt(about = "generate shell completions")] + GenCompletions { + #[structopt(long, short, help = "set the shell for generating completions")] + shell: Shell, + + #[structopt(long, short, help = "set the output directory")] + out_dir: String, + }, } impl AtuinCmd { @@ -157,11 +167,18 @@ impl AtuinCmd { println!("{}", encode); Ok(()) } - Self::Uuid => { println!("{}", uuid_v4()); Ok(()) } + Self::GenCompletions { shell, out_dir } => { + AtuinCmd::clap().gen_completions(env!("CARGO_PKG_NAME"), shell, &out_dir); + println!( + "Shell completion for {} is generated in {:?}", + shell, out_dir + ); + Ok(()) + } } } } -- cgit v1.3.1