Feat: Implement 'cls' command using native OS calls - #79
Conversation
|
🚀 Hi @HossamSaberr! Thank you for contributing to MyCMD. A maintainer will review your PR shortly. 🎉 |
WalkthroughA "cls" command is added to clear the console screen using native OS methods (cmd /c cls for Windows, clear for Unix-like systems). The command is registered in the CLI registry with exception handling for execution failures. However, the registration appears duplicated in App.java. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/java/com/mycmd/commands/ClsCommand.java (1)
22-29: Consider validating that no arguments are provided.The documentation states "This command does not accept any arguments," but the implementation doesn't validate this. Users passing arguments will see them silently ignored, which could be confusing.
Consider adding validation at the start of the execute method:
@Override public void execute(String[] args, ShellContext context) { + if (args.length > 0) { + System.out.println("'cls' command does not accept any arguments."); + return; + } try {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/main/java/com/mycmd/App.java(1 hunks)src/main/java/com/mycmd/commands/ClsCommand.java(1 hunks)
🔇 Additional comments (1)
src/main/java/com/mycmd/commands/ClsCommand.java (1)
23-35: Implementation looks solid.The OS detection and ProcessBuilder approach is appropriate for invoking native clear-screen commands. The use of
inheritIO()ensures the command interacts with the actual terminal, andwaitFor()properly blocks until completion. Exception handling correctly restores the interrupted status forInterruptedExceptionand provides user feedback for failures.
|
🚀 Hi @HossamSaberr! Thank you for contributing to MyCMD. A maintainer will review your PR shortly. 🎉 |
|
I merged it. Thanks for Contributing here @HossamSaberr. And now you can join our org too. You are invited. |
Hi! This PR adds the implementation for the
clscommand.It uses
ProcessBuilderto call the native OS command (clson Windows,clearon macOS/Linux). This provides a true screen-clearing functionality as discussed in the issue.Closes #6
Summary by CodeRabbit