Skip to content

Commit

Permalink
Make cli args configurable through env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
koarlchen committed Dec 26, 2024
1 parent cea2633 commit 82ebe48
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ chrono = "0.4.38"
thiserror = "1.0.65"
log = "0.4.22"
simple_logger = { version = "5.0.0", default-features = false, features = ["timestamps"] }
clap = { version = "4.5.20", features = ["derive"] }
clap = { version = "4.5.20", features = ["derive", "env"] }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ You may have a look in the Space API specification on how to fill the fields.

By default, the app will look for both the configuration (`config.json`) and template (`template.json`) files in the current working directory.

In case the files are located somewhere different, you can use the optional commandline arguments to provide the correct paths.
In case the files are located somewhere different, you can use the optional commandline arguments or their corresponding environment variables to provide the correct paths.
Just run `./k4status --help` to show their usage.

Next to the file paths, you can adjust the log level.
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const FILE_CONFIG: &str = "config.json";
const FILE_TEMPLATE: &str = "template.json";

#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
#[command(version, about)]
struct Args {
#[arg(short, long, default_value = FILE_CONFIG)]
#[arg(short, long, env = "K4S_CONFIG", default_value = FILE_CONFIG)]
config: String,

#[arg(short, long, default_value = FILE_TEMPLATE)]
#[arg(short, long, env = "K4S_TEMPLATE", default_value = FILE_TEMPLATE)]
template: String,
}

Expand Down

0 comments on commit 82ebe48

Please sign in to comment.