aboutsummaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
authorOrhun Parmaksız <orhunparmaksiz@gmail.com>2021-12-11 02:59:39 +0300
committerGitHub <noreply@github.com>2021-12-10 23:59:39 +0000
commit0abd063e018ecb8851c3a816aa941dd04d594c9e (patch)
treee61f6858727989bf7d848d7dab76632e6657b222 /src/command
parentUpdate messages in install.sh about the AUR packages (#231) (diff)
downloadatuin-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')
-rw-r--r--src/command/mod.rs19
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(())
+ }
}
}
}