better debug command parsing
This commit is contained in:
parent
74dc5ccfb4
commit
48e794861b
1 changed files with 7 additions and 6 deletions
|
@ -22,19 +22,20 @@ impl FromStr for Commands {
|
|||
type Err = CommandErr;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let lower = s.trim().to_lowercase();
|
||||
let trimmed = s.trim().to_lowercase();
|
||||
let words: Vec<&str> = trimmed.split_whitespace().collect();
|
||||
|
||||
match lower.as_str() {
|
||||
"step" => Ok(Self::Step),
|
||||
"continue" => Ok(Self::Continue),
|
||||
_ if let Some(addr) = lower.strip_prefix("watch") => {
|
||||
match words.as_slice() {
|
||||
["step"] => Ok(Self::Step),
|
||||
["continue"] => Ok(Self::Continue),
|
||||
["watch", addr] => {
|
||||
if let Ok(addr) = u16::from_str_radix(addr.trim().trim_start_matches("0x"), 16) {
|
||||
Ok(Self::Watch(addr))
|
||||
} else {
|
||||
Err(CommandErr::InvalidArgument)
|
||||
}
|
||||
}
|
||||
_ if let Some(addr) = lower.strip_prefix("break") => {
|
||||
["break", addr] => {
|
||||
if let Ok(addr) = u16::from_str_radix(addr.trim().trim_start_matches("0x"), 16) {
|
||||
Ok(Self::Break(addr))
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue