aboutsummaryrefslogtreecommitdiffstats
path: root/src/command/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/command/mod.rs50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/command/mod.rs b/src/command/mod.rs
index ca7fc724..393936b0 100644
--- a/src/command/mod.rs
+++ b/src/command/mod.rs
@@ -1,4 +1,5 @@
-use clap::Subcommand;
+use clap::{CommandFactory, Subcommand};
+use clap_complete::{generate, generate_to, Shell};
use eyre::Result;
#[cfg(feature = "client")]
@@ -7,6 +8,8 @@ mod client;
#[cfg(feature = "server")]
mod server;
+mod init;
+
#[derive(Subcommand)]
#[clap(infer_subcommands = true)]
pub enum AtuinCmd {
@@ -18,6 +21,24 @@ pub enum AtuinCmd {
#[cfg(feature = "server")]
#[clap(subcommand)]
Server(server::Cmd),
+
+ /// Output shell setup
+ #[clap(subcommand)]
+ Init(init::Cmd),
+
+ /// Generate a UUID
+ Uuid,
+
+ /// Generate shell completions
+ GenCompletions {
+ /// Set the shell for generating completions
+ #[clap(long, short)]
+ shell: Shell,
+
+ /// Set the output directory
+ #[clap(long, short)]
+ out_dir: Option<String>,
+ },
}
impl AtuinCmd {
@@ -27,6 +48,33 @@ impl AtuinCmd {
Self::Client(client) => client.run(),
#[cfg(feature = "server")]
Self::Server(server) => server.run(),
+ Self::Init(init) => {
+ init.run();
+ Ok(())
+ }
+ Self::Uuid => {
+ println!("{}", atuin_common::utils::uuid_v4());
+ Ok(())
+ }
+ Self::GenCompletions { shell, out_dir } => {
+ let mut cli = crate::Atuin::command();
+
+ match out_dir {
+ Some(out_dir) => {
+ generate_to(shell, &mut cli, env!("CARGO_PKG_NAME"), &out_dir)?;
+ }
+ None => {
+ generate(
+ shell,
+ &mut cli,
+ env!("CARGO_PKG_NAME"),
+ &mut std::io::stdout(),
+ );
+ }
+ }
+
+ Ok(())
+ }
}
}
}