-
-
Notifications
You must be signed in to change notification settings - Fork 4
CLI improvements #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI improvements #212
Conversation
WalkthroughThe changes update the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI (main.rs)
participant FileSystem
participant Compiler
User->>CLI (main.rs): Launch with command and arguments
CLI (main.rs)->>CLI (main.rs): Parse arguments
alt Not enough args / Unknown command / Missing arg
CLI (main.rs)->>User: Print error and usage/help
else run command
CLI (main.rs)->>handle_run: Call with file path
handle_run->>FileSystem: Access file
handle_run->>Compiler: compile_and_run(file)
Compiler-->>handle_run: Result
handle_run-->>CLI (main.rs): Result
CLI (main.rs)->>User: Output result
else help command
CLI (main.rs)->>User: Print help message
end
Possibly related PRs
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Clippy (1.86.0)warning: failed to write cache, path: /usr/local/registry/index/index.crates.io-1949cf8c6b5b557f/.cache/re/ge/regex, error: Permission denied (os error 13) Caused by: ✨ 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:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/main.rs (1)
75-80: Good encapsulation of unsafe operation.The
handle_runfunction properly isolates the unsafecompile_and_runcall. Consider enhancing error handling if the underlyingcompile_and_runfunction could be modified to returnResultfor better error propagation.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
.mailmap(1 hunks)Cargo.toml(1 hunks)src/main.rs(1 hunks)test/test33.wave(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/main.rs (1)
src/lib.rs (2)
compile_and_run(7-9)version_wave(11-13)
🔇 Additional comments (10)
Cargo.toml (1)
3-3: Version update looks good.The nightly build version format is appropriate for pre-release software. Note that the date "2025-07-16" appears to be in the future, which may be intentional for nightly builds.
.mailmap (1)
1-5: Excellent consolidation of author identities.The .mailmap update properly consolidates multiple email addresses and name variations under a single canonical identity, which will ensure consistent author attribution across the codebase.
test/test33.wave (1)
28-28: Good syntax fix.Adding the missing semicolon corrects the syntax error and aligns with the language's requirements.
src/main.rs (7)
1-2: Good import additions.The new imports for
fmtandprocessmodules, along withPath, are appropriate for the enhanced error handling and CLI functionality.
7-15: Well-designed error enum.The
CliErrorenum effectively covers the main CLI error scenarios with clear, descriptive variants. TheMissingArgumentvariant with structured fields for command and expected argument is particularly well thought out.
17-37: Excellent error message implementation.The
Displayimplementation provides clear, user-friendly error messages with consistent colored formatting. Each error variant is handled appropriately with descriptive messages that guide users on what went wrong.
39-45: Excellent main function structure.The refactored main function follows Rust best practices by delegating to a fallible
run()function and properly handling errors with informative messages and usage instructions.
47-73: Excellent refactoring of CLI argument parsing.The iterator-based approach is more efficient than the previous vector collection method. The explicit error handling with the
?operator and proper command matching significantly improves the robustness of the CLI.
82-86: Clean usage message function.The
print_usagefunction provides a clear, consistently formatted usage message that complements the error handling.
88-101: Comprehensive and well-formatted help message.The
print_helpfunction provides excellent user guidance with a clear description, usage information, and detailed command explanations. The consistent color scheme enhances readability.
I repurposed the CLI to look good.
Summary by CodeRabbit
Bug Fixes
Refactor
Chores