use clap::{Args, Subcommand};
use eyre::Result;
use atuin_client::record::sqlite_store::SqliteStore;
use atuin_client::settings::Settings;
pub mod change_password;
pub mod delete;
pub mod link;
pub mod login;
pub mod logout;
pub mod register;
#[derive(Args, Debug)]
pub struct Cmd {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Login(login::Cmd),
Register(register::Cmd),
Logout,
Delete(delete::Cmd),
ChangePassword(change_password::Cmd),
Link,
}
impl Cmd {
pub async fn run(self, settings: Settings, store: SqliteStore) -> Result<()> {
match self.command {
Commands::Login(l) => l.run(&settings, &store).await,
Commands::Register(r) => r.run(&settings, &store).await,
Commands::Logout => logout::run().await,
Commands::Delete(d) => d.run(&settings).await,
Commands::ChangePassword(c) => c.run(&settings).await,
Commands::Link => link::run(&settings).await,
}
}
}