mirror of
https://github.com/figsoda/mmtc
synced 2024-11-10 10:14:13 +00:00
add support for MPD_HOST and MPD_PORT env vars
This commit is contained in:
parent
eefe368b0b
commit
5259706206
2 changed files with 17 additions and 2 deletions
|
@ -57,6 +57,13 @@ option | description
|
|||
--ups \<number> | The amount of status updates per second
|
||||
|
||||
|
||||
## Environment variables
|
||||
|
||||
Setting both `MPD_HOST` and `MPD_PORT` is the equalvalent of `--address $MPD_HOST:$MPD_PORT`
|
||||
|
||||
Precedence: command line arguments > environment variables > configuration file
|
||||
|
||||
|
||||
## Key bindings
|
||||
|
||||
Key | Action
|
||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -26,8 +26,9 @@ use tui::{backend::CrosstermBackend, widgets::ListState, Terminal};
|
|||
|
||||
use std::{
|
||||
cmp::min,
|
||||
fs,
|
||||
env, fs,
|
||||
io::stdout,
|
||||
net::SocketAddr,
|
||||
process::exit,
|
||||
sync::{
|
||||
atomic::{AtomicU8, Ordering},
|
||||
|
@ -84,7 +85,14 @@ async fn run() -> Result<()> {
|
|||
defaults::config()
|
||||
};
|
||||
|
||||
let addr = &opts.address.unwrap_or(cfg.address);
|
||||
let addr = &if let Some(addr) = opts.address {
|
||||
addr
|
||||
} else if let (Ok(host), Ok(port)) = (env::var("MPD_HOST"), env::var("MPD_PORT")) {
|
||||
SocketAddr::new(host.parse()?, port.parse()?)
|
||||
} else {
|
||||
cfg.address
|
||||
};
|
||||
|
||||
let mut idle_cl = Client::init(addr).await?;
|
||||
let mut cl = Client::init(addr).await?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue