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)]
|
#[clap(version, author, about)]
|
||||||
struct Opts {
|
struct Opts {
|
||||||
/// Home Assistant host
|
/// Home Assistant host
|
||||||
#[clap(short, long)]
|
#[clap(short, long, env = "HNP_HOST")]
|
||||||
host: String,
|
host: String,
|
||||||
|
|
||||||
/// Media player entity ID
|
/// Media player entity ID
|
||||||
#[clap(short, long)]
|
#[clap(short, long, env = "HNP_ENTITY")]
|
||||||
entity: String,
|
entity: String,
|
||||||
|
|
||||||
/// API token
|
/// API token
|
||||||
#[clap(short, long, env)]
|
#[clap(short, long, env = "HNP_TOKEN")]
|
||||||
token: Option<String>,
|
token: Option<String>,
|
||||||
|
|
||||||
/// File with the API token
|
/// File with the API token
|
||||||
#[clap(long, env)]
|
#[clap(long, env, env = "HNP_TOKEN_FILE")]
|
||||||
token_file: Option<PathBuf>,
|
token_file: Option<PathBuf>,
|
||||||
|
|
||||||
/// Use HTTP instead of HTTPS
|
/// Use HTTP instead of HTTPS
|
||||||
#[clap(short, long)]
|
#[clap(short, long, env = "HNP_INSECURE")]
|
||||||
insecure: bool,
|
insecure: bool,
|
||||||
|
|
||||||
/// Output format
|
/// 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,
|
format: output::OutputFormat,
|
||||||
|
|
||||||
#[clap(short, long)]
|
#[clap(short, long, env = "HNP_DEBUG")]
|
||||||
debug: bool,
|
debug: bool,
|
||||||
|
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
|
|
Loading…
Reference in a new issue