Allow options to be set from environment variables

This commit is contained in:
Erwin Boskma 2022-11-05 10:43:29 +01:00
parent 22b6ecdd4a
commit 151ebbe8a6
Signed by: erwin
SSH key fingerprint: SHA256:CyeNoWXd3kjX2Nwu6pDxxdS7OqmPVOy0NavA/KU/ntU

View file

@ -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<String>,
/// File with the API token
#[clap(long, env)]
#[clap(long, env, env = "HNP_TOKEN_FILE")]
token_file: Option<PathBuf>,
/// 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)]