mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-12-27 04:53:50 +03:00
feat: allow specifying config path via command flag
This commit is contained in:
parent
60a2f2d011
commit
9a88386ddf
2 changed files with 6 additions and 2 deletions
|
@ -22,6 +22,10 @@ fn version() -> String {
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub command: Option<Commands>,
|
pub command: Option<Commands>,
|
||||||
|
|
||||||
|
/// Path to the config file
|
||||||
|
#[arg(short, long, value_name = "PATH")]
|
||||||
|
pub config: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
|
|
|
@ -55,10 +55,10 @@ static GLOBAL: Jemalloc = Jemalloc;
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let cli = clap::parse();
|
let cli = clap::parse();
|
||||||
|
|
||||||
let path =
|
let path = cli.config.unwrap_or_else(|| {
|
||||||
Env::var("CONDUIT_CONFIG")
|
Env::var("CONDUIT_CONFIG")
|
||||||
.expect("The config path must either be set via the -c/--config flag or the CONDUIT_CONFIG env var. Example: /etc/conduit.toml")
|
.expect("The config path must either be set via the -c/--config flag or the CONDUIT_CONFIG env var. Example: /etc/conduit.toml")
|
||||||
;
|
});
|
||||||
|
|
||||||
match cli.command {
|
match cli.command {
|
||||||
Some(Commands::GenerateConfig) => {
|
Some(Commands::GenerateConfig) => {
|
||||||
|
|
Loading…
Reference in a new issue