Add cmd line parser (#512)

This commit adds the clap library and configures the necessary args to
parse from the command line,  expanding the current option of a single
file and adding support for environment variables.

Signed-off-by: Sebastian Webber <sebastian@swebber.me>
This commit is contained in:
Sebastian Webber
2023-07-18 17:52:40 -03:00
committed by GitHub
parent 5d87e3781e
commit 7bdb4e5cd9
6 changed files with 495 additions and 343 deletions

17
src/cmd_args.rs Normal file
View File

@@ -0,0 +1,17 @@
use clap::Parser;
use log::LevelFilter;
/// PgCat: Nextgen PostgreSQL Pooler
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub(crate) struct Args {
#[arg(default_value_t = String::from("pgcat.toml"), env)]
pub config_file: String,
#[arg(short, long, default_value_t = LevelFilter::Info, env)]
pub log_level: log::LevelFilter,
}
pub(crate) fn parse() -> Args {
return Args::parse();
}