1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
use clap::{Args, Subcommand};
use eyre::Result;
use crate::atuin_client::record::sqlite_store::SqliteStore;
use crate::atuin_client::settings::Settings;
pub(crate) mod change_password;
pub(crate) mod delete;
pub(crate) mod login;
pub(crate) mod logout;
pub(crate) mod register;
#[derive(Args, Debug)]
pub(crate) struct Cmd {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand, Debug)]
pub(crate) enum Commands {
/// Login to the configured server
Login(login::Cmd),
/// Register a new account
Register(register::Cmd),
/// Log out
Logout,
/// Delete your account, and all synced data
Delete(delete::Cmd),
/// Change your password
ChangePassword(change_password::Cmd),
}
impl Cmd {
pub(crate) 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).await,
Commands::Logout => logout::run().await,
Commands::Delete(d) => d.run(&settings).await,
Commands::ChangePassword(c) => c.run(&settings).await,
}
}
}
|