From 432acd246f10e5cd1b2593665a1b094d8d378eba Mon Sep 17 00:00:00 2001 From: Robert Zhu Date: Sat, 15 Jun 2024 21:34:27 -0700 Subject: [PATCH] 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" => {