From 151ebbe8a650ea673146e08ab7dfd95075062184 Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Sat, 5 Nov 2022 10:43:29 +0100 Subject: [PATCH] Allow options to be set from environment variables --- src/main.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7f4fc8b..f72a524 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,30 +18,36 @@ mod output; #[clap(version, author, about)] struct Opts { /// Home Assistant host - #[clap(short, long)] + #[clap(short, long, env = "HNP_HOST")] host: String, /// Media player entity ID - #[clap(short, long)] + #[clap(short, long, env = "HNP_ENTITY")] entity: String, /// API token - #[clap(short, long, env)] + #[clap(short, long, env = "HNP_TOKEN")] token: Option, /// File with the API token - #[clap(long, env)] + #[clap(long, env, env = "HNP_TOKEN_FILE")] token_file: Option, /// Use HTTP instead of HTTPS - #[clap(short, long)] + #[clap(short, long, env = "HNP_INSECURE")] insecure: bool, /// Output format - #[clap(arg_enum, short, long, default_value = "waybar")] + #[clap( + arg_enum, + short, + long, + env = "HNP_OUTPUT_FORMAT", + default_value = "waybar" + )] format: output::OutputFormat, - #[clap(short, long)] + #[clap(short, long, env = "HNP_DEBUG")] debug: bool, #[clap(subcommand)]