-
Notifications
You must be signed in to change notification settings - Fork 222
/
Copy pathcmd_args.rs
59 lines (49 loc) · 1.18 KB
/
cmd_args.rs
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
use clap::{Parser, Subcommand, ValueEnum};
use tracing::Level;
/// PgCat: Nextgen PostgreSQL Pooler
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Args {
#[arg(default_value_t = String::from("pgcat.toml"), env)]
pub config_file: String,
#[arg(short, long, default_value_t = tracing::Level::INFO, env)]
pub log_level: Level,
#[clap(short='F', long, value_enum, default_value_t=LogFormat::Text, env)]
pub log_format: LogFormat,
#[arg(
short,
long,
default_value_t = false,
env,
help = "disable colors in the log output"
)]
pub no_color: bool,
#[command(subcommand)]
pub command: Option<Commands>,
}
pub fn parse() -> Args {
Args::parse()
}
#[derive(ValueEnum, Clone, Debug)]
pub enum LogFormat {
Text,
Structured,
Debug,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
#[command(subcommand)]
Config(ConfigSubcommands),
}
#[derive(Subcommand, Debug)]
pub enum ConfigSubcommands {
#[command(subcommand)]
Pools(ConfigPoolsSubcommands),
Shards,
}
#[derive(Subcommand, Debug)]
pub enum ConfigPoolsSubcommands {
List,
Add,
Remove,
}