From 045c87fbcd1cb8efe8bd3a41f55790b326ed6ee4 Mon Sep 17 00:00:00 2001 From: c-14 Date: Sun, 25 Sep 2022 12:15:33 +0200 Subject: Allow stateless commands to be run without config/database (#544) * Allow stateless commands to be run without config/database Fixes an issue where gen-completions fails trying to create a config directory in restrained build environments/distribution. * move non-db commands up to core subcommands * re-add lost lines * re-add lost lines Co-authored-by: Conrad Ludgate --- src/command/init.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/command/init.rs (limited to 'src/command/init.rs') diff --git a/src/command/init.rs b/src/command/init.rs new file mode 100644 index 00000000..37453f93 --- /dev/null +++ b/src/command/init.rs @@ -0,0 +1,36 @@ +use clap::Parser; + +#[derive(Parser)] +pub enum Cmd { + /// Zsh setup + Zsh, + /// Bash setup + Bash, + /// Fish setup + Fish, +} + +fn init_zsh() { + let full = include_str!("../shell/atuin.zsh"); + println!("{}", full); +} + +fn init_bash() { + let full = include_str!("../shell/atuin.bash"); + println!("{}", full); +} + +fn init_fish() { + let full = include_str!("../shell/atuin.fish"); + println!("{}", full); +} + +impl Cmd { + pub fn run(&self) { + match self { + Self::Zsh => init_zsh(), + Self::Bash => init_bash(), + Self::Fish => init_fish(), + } + } +} -- cgit v1.3.1