From afca9a779447a599fae3ba05406f7a47baec5dec Mon Sep 17 00:00:00 2001 From: Robert Zhu Date: Fri, 14 Jun 2024 10:27:41 -0400 Subject: [PATCH 1/2] Default to default action Removes previous parse error. --- src/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli.rs b/src/cli.rs index 91a0787..4324091 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -137,7 +137,7 @@ pub fn handle_socket_message( let id = get_window_id(notif_id, manager)?; let action = action_id .parse::() - .map_err(|_| CLIError::Parse("Value is not of type usize."))?; + .unwrap_or(0); manager.trigger_action_idx(id, action); } "show" => { From 432acd246f10e5cd1b2593665a1b094d8d378eba Mon Sep 17 00:00:00 2001 From: Robert Zhu Date: Sat, 15 Jun 2024 21:34:27 -0700 Subject: [PATCH 2/2] Use explicit matching --- src/cli.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 4324091..fcda7a0 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -135,9 +135,13 @@ pub fn handle_socket_message( .ok_or(CLIError::Parse("Malformed action request."))?; let id = get_window_id(notif_id, manager)?; - let action = action_id - .parse::() - .unwrap_or(0); + let action = match action_id { + "default" => 0, + _ => { action_id + .parse::() + .map_err(|_| CLIError::Parse("Value is not of type usize."))? + } + }; manager.trigger_action_idx(id, action); } "show" => {