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
|
use eyre::Result;
use structopt::StructOpt;
use uuid::Uuid;
use crate::local::database::Sqlite;
mod history;
mod import;
mod server;
#[derive(StructOpt)]
pub enum AtuinCmd {
#[structopt(
about="manipulate shell history",
aliases=&["h", "hi", "his", "hist", "histo", "histor"],
)]
History(history::Cmd),
#[structopt(about = "import shell history from file")]
Import(import::Cmd),
#[structopt(about = "start an atuin server")]
Server(server::Cmd),
#[structopt(about = "generates a UUID")]
Uuid,
}
pub fn uuid_v4() -> String {
Uuid::new_v4().to_simple().to_string()
}
impl AtuinCmd {
pub fn run(self, db: &mut Sqlite) -> Result<()> {
match self {
Self::History(history) => history.run(db),
Self::Import(import) => import.run(db),
Self::Server(server) => server.run(),
Self::Uuid => {
println!("{}", uuid_v4());
Ok(())
}
}
}
}
|