Skip to content

feat(pwd): implement the pwd builtin#9

Merged
Pawank06 merged 3 commits intomainfrom
feature/pwd
Jan 4, 2026
Merged

feat(pwd): implement the pwd builtin#9
Pawank06 merged 3 commits intomainfrom
feature/pwd

Conversation

@Pawank06
Copy link
Owner

@Pawank06 Pawank06 commented Jan 4, 2026

summary

  • add the pwd builtin command
  • print the current working directory

notes

  • implemented as a shell builtin
  • matches basic unix shell behavior

Summary by CodeRabbit

  • New Features
    • Added a pwd command to display the current working directory in rshell.
    • The command prints the directory on success and emits a clear error message if the directory cannot be determined.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 4, 2026

📝 Walkthrough

Walkthrough

Adds a new built-in "pwd" to rshell: the command is recognized and prints the current working directory; failures emit an error message and execution continues. (47 words)

Changes

Cohort / File(s) Summary
pwd builtin implementation
src/main.rs
Adds "pwd" to the builtins list and a match arm that obtains and prints the current working directory; on error it prints an error message and continues execution.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I hop through paths both wide and small,
A tiny "pwd" to show them all,
From root to burrow, lit and true,
I whisper where the shell will view,
A carrot trail of cwd for you 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(pwd): implement the pwd builtin' clearly and concisely describes the main change—adding a pwd builtin command to the shell, which aligns with the changeset modifications in src/main.rs.
✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main.rs (1)

75-81: Optional: Format and style improvements.

Minor style inconsistencies that could be addressed:

  • Missing space before opening brace on line 76: current_dir() {
  • Inconsistent indentation (appears to use 2 spaces instead of 4)
  • Trailing empty line at line 80
🔎 Formatting suggestion
 "pwd" => {
-    match env::current_dir(){
-      Ok(val) => println!("{}", val.display()),
-      Err(_) => continue,
-  }
-  
+    match env::current_dir() {
+        Ok(val) => println!("{}", val.display()),
+        Err(_) => continue,
+    }
 },
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd06b20 and fc6d8e8.

📒 Files selected for processing (1)
  • src/main.rs
🔇 Additional comments (1)
src/main.rs (1)

39-39: LGTM! Builtin registration is correct.

The addition of "pwd" to the builtin array properly registers it so the type command can identify it as a shell builtin.

Copy link

@coderabbitai coderabbitai bot left a 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-81: Good fix! Previous feedback addressed.

The error handling now correctly prints to stderr when pwd fails, which matches standard Unix shell behavior and addresses the previous review feedback.

Minor formatting suggestion: The indentation within this match arm uses 2-space increments while the rest of the file uses 4 spaces, and there's an extra blank line before the closing brace. For consistency:

🔎 Optional formatting improvement
 "pwd" => {
     match env::current_dir(){
-      Ok(val) => println!("{}", val.display()),
-      Err(e) => eprintln!("pwd: {}", e),
-  }
-  
+        Ok(val) => println!("{}", val.display()),
+        Err(e) => eprintln!("pwd: {}", e),
+    }
 },
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc6d8e8 and 5232ecc.

📒 Files selected for processing (1)
  • src/main.rs
🔇 Additional comments (1)
src/main.rs (1)

39-39: LGTM! Builtin list correctly updated.

The addition of "pwd" to the builtin list ensures that type pwd correctly reports it as a shell builtin.

@Pawank06 Pawank06 merged commit 6220a3f into main Jan 4, 2026
2 checks passed
@Pawank06 Pawank06 deleted the feature/pwd branch January 4, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant