Skip to content

Conversation

@zohrehKazemianpour
Copy link

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

This PR contains implementing shell tools (cat, ls, wc) in JavaScript with NodeJS using the commander library.

@zohrehKazemianpour zohrehKazemianpour added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 20, 2025
@zohrehKazemianpour zohrehKazemianpour changed the title London | 25-SDC-Nov | Zohreh Kazemianpour | Sprint 3 | Shell-NodeJS London | 25-SDC-Nov | Zohreh Kazemianpour | Sprint 3 | Implement-Shell-Tools-NodeJS Nov 23, 2025
@zohrehKazemianpour zohrehKazemianpour changed the title London | 25-SDC-Nov | Zohreh Kazemianpour | Sprint 3 | Implement-Shell-Tools-NodeJS London | 25-SDC-Nov | Zohreh Kazemianpour | Sprint 3 | Implement Shell Tools-NodeJS Nov 23, 2025
Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

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

Good work on these tasks, sorry for the delay in getting a review.

Good use of comments to explain throughout.

There are some places you could improve implementations further

// Process each file
for (const path of program.args) {
const hasNumberFlag = program.opts().number; // True if user used -n flag
const hasBFlag = program.opts().numberNonBlank;

Choose a reason for hiding this comment

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

Do you think the name "hasBFlag" explains well what the variable is doing?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for catching this. No, it's not descriptive at all. I needed to read the program carefully to fully understand what it was doing. I've changed it to shouldNumberNonBlank.

return line;
} else {
lineNumber = lineNumber + 1;
return ` ${lineNumber} ${line}`;

Choose a reason for hiding this comment

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

There is some duplication here, can you see any way to make this code a bit more concise?

Copy link
Author

Choose a reason for hiding this comment

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

That is right, the return statement is used twice. I used the ternary operator to remove the redundant ones.

program
.name("ls")
.description("list directory contents")
.option("-1, --one", "Force output to be one entry per line")

Choose a reason for hiding this comment

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

You include the 1 option here, do you ever use it?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for pointing that out. I realized the flag wasn't doing anything because my output was always vertical. I’ve refactored it to be horizontal by default, so the -1 flag now correctly 'forces' the single-column output.

Choose a reason for hiding this comment

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

Good implementation!

Copy link
Author

Choose a reason for hiding this comment

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

Hi @LonMcGregor ,

I hope you had a lovely holiday.

Thanks for your patience with this! It took me a bit longer to get back to these changes as I had to step away for a week to complete my English and Life in the UK tests, which was immediately followed by the Christmas break.
I've now addressed all the feedback.

Happy New Year to you, and I look forward to your thoughts on the updates!

@LonMcGregor LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Dec 17, 2025
@zohrehKazemianpour zohrehKazemianpour added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jan 4, 2026
@LonMcGregor
Copy link

Good work on these updates, this task looks complete now!

@LonMcGregor LonMcGregor added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Jan 5, 2026
@zohrehKazemianpour
Copy link
Author

Good work on these updates, this task looks complete now!

Thanks for the complete label!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants