Skip to content

Commit 8ea0c31

Browse files
authored
Debugger: Fix command parsing on the debugger prompt (#1074)
* Fix debugger parser * Forgot to change to command for one line
1 parent 4240479 commit 8ea0c31

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

debugger/src/main.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,51 +130,52 @@ impl Cli {
130130
}
131131

132132
fn execute_command(&mut self, command: &str) -> Result<(), DebuggerError> {
133-
match command {
133+
let verb = command.split(&[' ', '\t']).next().unwrap().trim();
134+
match verb {
134135
"" => (),
135136
help if "help".starts_with(help) => Cli::help(),
136137
list if "list".starts_with(list) => self.list(),
137138
cont if "continue".starts_with(cont) => self.cont()?,
138139
"ba" => self.context.add_all_rules_breakpoints()?,
139140
"da" => self.context.delete_all_breakpoints(),
140141
grammar if "grammar".starts_with(grammar) => {
141-
let grammar_file = Self::extract_arg(grammar);
142+
let grammar_file = Self::extract_arg(command);
142143
if let Some(grammar_file) = grammar_file {
143144
self.grammar(PathBuf::from(grammar_file))?;
144145
} else {
145146
println!("expected filename, usage: g(grammar) <filename>");
146147
}
147148
}
148149
input if "input".starts_with(input) => {
149-
let input_file = Self::extract_arg(input);
150+
let input_file = Self::extract_arg(command);
150151
if let Some(input_file) = input_file {
151152
self.input(PathBuf::from(input_file))?;
152153
} else {
153154
println!("expected filename, usage: i(input) <filename>");
154155
}
155156
}
156157
x if x.starts_with("id ") => {
157-
let input = &x[3..];
158+
let input = &command[3..];
158159
self.context.load_input_direct(input.to_owned());
159160
}
160161
breakpoint if "breakpoint".starts_with(breakpoint) => {
161-
let rule = Self::extract_arg(breakpoint);
162+
let rule = Self::extract_arg(command);
162163
if let Some(rule) = rule {
163164
self.breakpoint(rule);
164165
} else {
165166
println!("expected rule, usage: b(breakpoint) <rule>");
166167
}
167168
}
168169
delete if "delete".starts_with(delete) => {
169-
let rule = Self::extract_arg(delete);
170+
let rule = Self::extract_arg(command);
170171
if let Some(rule) = rule {
171172
self.context.delete_breakpoint(rule);
172173
} else {
173174
println!("expected rule, usage: d(delete) <rule>");
174175
}
175176
}
176177
run if "run".starts_with(run) => {
177-
let rule = Self::extract_arg(run);
178+
let rule = Self::extract_arg(command);
178179
if let Some(rule) = rule {
179180
self.run(rule)?;
180181
} else {

0 commit comments

Comments
 (0)