From 96ac028918baa1094374e823a2464016f7f20479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sat, 26 Dec 2020 22:33:10 +0100 Subject: add todos --- mumctl/src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'mumctl') diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs index 298c04f..a3a1a06 100644 --- a/mumctl/src/main.rs +++ b/mumctl/src/main.rs @@ -191,10 +191,10 @@ fn main() { let stdin = std::io::stdin(); let response = stdin.lock().lines().next(); if let Some(Ok(true)) = response.map(|e| e.map(|e| &e == "Y")) { - config.write_default_cfg(true).unwrap(); + config.write_default_cfg(true).unwrap(); //TODO handle panic } } else { - config.write_default_cfg(false).unwrap(); + config.write_default_cfg(false).unwrap(); //TODO handle panic } } @@ -276,13 +276,13 @@ fn process_matches(matches: ArgMatches, config: &mut Config, app: &mut App) -> R match name { "audio.input_volume" => { if let Ok(volume) = value.parse() { - send_command(Command::InputVolumeSet(volume))?.unwrap(); + send_command(Command::InputVolumeSet(volume))?.unwrap(); //TODO error_if_err config.audio.input_volume = Some(volume); } } "audio.output_volume" => { if let Ok(volume) = value.parse() { - send_command(Command::OutputVolumeSet(volume))?.unwrap(); + send_command(Command::OutputVolumeSet(volume))?.unwrap(); //TODO error_if_err config.audio.output_volume = Some(volume); } } @@ -291,7 +291,7 @@ fn process_matches(matches: ArgMatches, config: &mut Config, app: &mut App) -> R } } } else if matches.subcommand_matches("config-reload").is_some() { - send_command(Command::ConfigReload)?.unwrap(); + send_command(Command::ConfigReload)?.unwrap(); //TODO error_if_err } else if let Some(matches) = matches.subcommand_matches("completions") { app.gen_completions_to( "mumctl", -- cgit v1.2.1 From 5d9716ec34413533ca47166e6764ca6e37a9fc0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sat, 26 Dec 2020 22:39:42 +0100 Subject: mumctl: error_if_err! --- mumctl/src/main.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'mumctl') diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs index a3a1a06..812c97b 100644 --- a/mumctl/src/main.rs +++ b/mumctl/src/main.rs @@ -202,11 +202,7 @@ fn process_matches(matches: ArgMatches, config: &mut Config, app: &mut App) -> R if let Some(matches) = matches.subcommand_matches("connect") { match_server_connect(matches, &config)?; } else if let Some(_) = matches.subcommand_matches("disconnect") { - match send_command(Command::ServerDisconnect) { - Ok(v) => error_if_err!(v), - Err(e) => error!("{}", e), - } - // error_if_err!(send_command(Command::ServerDisconnect)); + error_if_err!(send_command(Command::ServerDisconnect)?); } else if let Some(matches) = matches.subcommand_matches("server") { if let Some(matches) = matches.subcommand_matches("config") { match_server_config(matches, config); @@ -276,13 +272,13 @@ fn process_matches(matches: ArgMatches, config: &mut Config, app: &mut App) -> R match name { "audio.input_volume" => { if let Ok(volume) = value.parse() { - send_command(Command::InputVolumeSet(volume))?.unwrap(); //TODO error_if_err + error_if_err!(send_command(Command::InputVolumeSet(volume))?); config.audio.input_volume = Some(volume); } } "audio.output_volume" => { if let Ok(volume) = value.parse() { - send_command(Command::OutputVolumeSet(volume))?.unwrap(); //TODO error_if_err + error_if_err!(send_command(Command::OutputVolumeSet(volume))?); config.audio.output_volume = Some(volume); } } @@ -291,7 +287,7 @@ fn process_matches(matches: ArgMatches, config: &mut Config, app: &mut App) -> R } } } else if matches.subcommand_matches("config-reload").is_some() { - send_command(Command::ConfigReload)?.unwrap(); //TODO error_if_err + error_if_err!(send_command(Command::ConfigReload)?); } else if let Some(matches) = matches.subcommand_matches("completions") { app.gen_completions_to( "mumctl", -- cgit v1.2.1 From 8c3a37b40260711ef13a6130a612537b64b78215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Tue, 30 Mar 2021 10:48:58 +0200 Subject: mumctl: more error_if_err --- mumctl/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mumctl') diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs index 812c97b..6535f79 100644 --- a/mumctl/src/main.rs +++ b/mumctl/src/main.rs @@ -191,10 +191,10 @@ fn main() { let stdin = std::io::stdin(); let response = stdin.lock().lines().next(); if let Some(Ok(true)) = response.map(|e| e.map(|e| &e == "Y")) { - config.write_default_cfg(true).unwrap(); //TODO handle panic + error_if_err!(config.write_default_cfg(true)); } } else { - config.write_default_cfg(false).unwrap(); //TODO handle panic + error_if_err!(config.write_default_cfg(false)); } } -- cgit v1.2.1 From 25687fb7c98f7d7d8b1f0a04d32092f394ec4c44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Tue, 30 Mar 2021 12:09:49 +0200 Subject: mumlib::config: dirs --- mumctl/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mumctl') diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs index 6535f79..2d9cd18 100644 --- a/mumctl/src/main.rs +++ b/mumctl/src/main.rs @@ -186,7 +186,7 @@ fn main() { if !config::cfg_exists() { println!( "Config file not found. Create one in {}? [Y/n]", - config::get_creatable_cfg_path() + config::default_cfg_path().display(), ); let stdin = std::io::stdin(); let response = stdin.lock().lines().next(); -- cgit v1.2.1 From 950158eaadd8db9ef0eb48187e825524499422d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Tue, 30 Mar 2021 12:36:53 +0200 Subject: config error --- mumctl/src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'mumctl') diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs index 2d9cd18..a187a3a 100644 --- a/mumctl/src/main.rs +++ b/mumctl/src/main.rs @@ -44,7 +44,13 @@ static LOGGER: SimpleLogger = SimpleLogger; fn main() { log::set_logger(&LOGGER) .map(|()| log::set_max_level(LevelFilter::Info)).unwrap(); - let mut config = config::read_default_cfg(); + let mut config = match config::read_default_cfg() { + Ok(c) => c, + Err(e) => { + error!("Couldn't read config: {}", e); + return; + } + }; let mut app = App::new("mumctl") .setting(AppSettings::ArgRequiredElseHelp) -- cgit v1.2.1