summaryrefslogtreecommitdiffstats
path: root/src/db/cli.rs
blob: d883bf7bcc588318bd6aead04447c7c86659e60e (plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use clap_v3 as clap;
use clap::App;
use clap::Arg;
use clap::crate_authors;
use clap::crate_version;

pub fn cli<'a>() -> App<'a> {
    App::new("db")
        .author(crate_authors!())
        .version(crate_version!())
        .about("Database CLI interface")

        .subcommand(App::new("cli")
            .about("Start a database CLI, if installed on the current host")
            .long_about(indoc::indoc!(r#"
                Starts a database shell on the configured database using one of the following
                programs:
                    - psql
                    - pgcli

                if installed.
            "#))

            .arg(Arg::with_name("tool")
                .required(false)
                .multiple(false)
                .long("tool")
                .value_name("TOOL")
                .possible_values(&["psql", "pgcli"])
                .help("Use a specific tool")
            )
        )

        .subcommand(App::new("artifacts")
            .about("List artifacts from the DB")
            .arg(Arg::with_name("csv")
                .required(false)
                .multiple(false)
                .long("csv")
                .takes_value(false)
                .help("Format output as CSV")
            )
        )

        .subcommand(App::new("envvars")
            .about("List envvars from the DB")
            .arg(Arg::with_name("csv")
                .required(false)
                .multiple(false)
                .long("csv")
                .takes_value(false)
                .help("Format output as CSV")
            )
        )

        .subcommand(App::new("images")
            .about("List images from the DB")
            .arg(Arg::with_name("csv")
                .required(false)
                .multiple(false)
                .long("csv")
                .takes_value(false)
                .help("Format output as CSV")
            )
        )

}