diff options
| author | Orhun Parmaksız <orhunparmaksiz@gmail.com> | 2021-12-11 02:59:39 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-10 23:59:39 +0000 |
| commit | 0abd063e018ecb8851c3a816aa941dd04d594c9e (patch) | |
| tree | e61f6858727989bf7d848d7dab76632e6657b222 /src/command/mod.rs | |
| parent | Update messages in install.sh about the AUR packages (#231) (diff) | |
| download | atuin-0abd063e018ecb8851c3a816aa941dd04d594c9e.zip | |
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
Diffstat (limited to 'src/command/mod.rs')
| -rw-r--r-- | src/command/mod.rs | 19 |
1 files changed, 18 insertions, 1 deletions
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(()) + } } } } |
