Allow options to be set from environment variables
This commit is contained in:
parent
22b6ecdd4a
commit
151ebbe8a6
1 changed files with 13 additions and 7 deletions
20
src/main.rs
20
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<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)]
|
||||
|
|
Loading…
Reference in a new issue