From aae887d99af226264d0ffcc14040c3574400cca2 Mon Sep 17 00:00:00 2001 From: Jonas Zaddach Date: Thu, 30 Jan 2025 21:05:51 +0100 Subject: [PATCH 1/2] Fix debugger parser --- debugger/src/main.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/debugger/src/main.rs b/debugger/src/main.rs index 6d6eb3ae..2740fcc6 100644 --- a/debugger/src/main.rs +++ b/debugger/src/main.rs @@ -130,7 +130,8 @@ impl Cli { } fn execute_command(&mut self, command: &str) -> Result<(), DebuggerError> { - match command { + let verb = command.split(&[' ', '\t']).next().unwrap().trim(); + match verb { "" => (), help if "help".starts_with(help) => Cli::help(), list if "list".starts_with(list) => self.list(), @@ -138,7 +139,7 @@ impl Cli { "ba" => self.context.add_all_rules_breakpoints()?, "da" => self.context.delete_all_breakpoints(), grammar if "grammar".starts_with(grammar) => { - let grammar_file = Self::extract_arg(grammar); + let grammar_file = Self::extract_arg(command); if let Some(grammar_file) = grammar_file { self.grammar(PathBuf::from(grammar_file))?; } else { @@ -146,7 +147,7 @@ impl Cli { } } input if "input".starts_with(input) => { - let input_file = Self::extract_arg(input); + let input_file = Self::extract_arg(command); if let Some(input_file) = input_file { self.input(PathBuf::from(input_file))?; } else { @@ -158,7 +159,7 @@ impl Cli { self.context.load_input_direct(input.to_owned()); } breakpoint if "breakpoint".starts_with(breakpoint) => { - let rule = Self::extract_arg(breakpoint); + let rule = Self::extract_arg(command); if let Some(rule) = rule { self.breakpoint(rule); } else { @@ -166,7 +167,7 @@ impl Cli { } } delete if "delete".starts_with(delete) => { - let rule = Self::extract_arg(delete); + let rule = Self::extract_arg(command); if let Some(rule) = rule { self.context.delete_breakpoint(rule); } else { @@ -174,7 +175,7 @@ impl Cli { } } run if "run".starts_with(run) => { - let rule = Self::extract_arg(run); + let rule = Self::extract_arg(command); if let Some(rule) = rule { self.run(rule)?; } else { From 06f4448e12b8056d84a7885b082cf523f881bce9 Mon Sep 17 00:00:00 2001 From: Jonas Zaddach Date: Thu, 30 Jan 2025 22:35:59 +0100 Subject: [PATCH 2/2] Forgot to change to command for one line --- debugger/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugger/src/main.rs b/debugger/src/main.rs index 2740fcc6..618f2a55 100644 --- a/debugger/src/main.rs +++ b/debugger/src/main.rs @@ -155,7 +155,7 @@ impl Cli { } } x if x.starts_with("id ") => { - let input = &x[3..]; + let input = &command[3..]; self.context.load_input_direct(input.to_owned()); } breakpoint if "breakpoint".starts_with(breakpoint) => {