debugger: fixed cli-parsing of id <text-input> command#1089
debugger: fixed cli-parsing of id <text-input> command#1089tomtau merged 1 commit intopest-parser:masterfrom
Conversation
WalkthroughThis change updates the command parsing in the debugger's Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant C as CLI
U->>C: Enters command "id<text>" or "id"
C->>C: Checks if command starts with "id"
C->>C: Calls extract_arg(command)
alt Argument provided
C->>C: Process command with extracted argument
else No argument provided
C->>U: Print error message with usage instructions
end
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
debugger/src/main.rs (1)
128-130: Good utility method for argument extraction.The implementation of
extract_argis a clean approach to safely extract command arguments. It separates this concern from the command processing logic, making the code more maintainable.Consider handling multiple spaces or tabs between the command and argument by trimming the extracted argument:
fn extract_arg(cmd: &str) -> Option<&str> { - cmd.find(' ').map(|pos| &cmd[pos + 1..]) + cmd.find(' ').map(|pos| &cmd[pos + 1..].trim_start()) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
debugger/src/main.rs(1 hunks)
🔇 Additional comments (1)
debugger/src/main.rs (1)
157-164: Fixed CLI parsing for the "id" command.This change correctly addresses the original issue by:
- Modifying the command recognition to check for strings starting with "id" without requiring a space after it
- Using the new
extract_argmethod to safely extract the argument- Adding proper error handling for cases where input text is missing
The implementation now correctly handles the command and provides meaningful feedback to users when input is missing.
Fixes #1088
Summary by CodeRabbit