Skip to content

Conversation

@delmorallopez
Copy link

Include the command cat, ls, wc

The changes meet the requirements of the task
I have tested my changes

Contains exercises to help you with task is to re-implement shell tools you have used.

Each folder is named after a group of tools, and contains exercises to practice using them.

@delmorallopez delmorallopez added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 3 Assigned during Sprint 3 of this module labels Nov 28, 2025
@delmorallopez delmorallopez force-pushed the Implement-Shell-Tools branch 2 times, most recently from 0e0d3f5 to af93a31 Compare November 30, 2025 18:35
@LonMcGregor LonMcGregor added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Jan 7, 2026
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 start on this task. In addition to the comments in the files, consider this: can you see any issues that might arise from the names you have given to your scripts?

program
.name("count-containing-words")
.description("Counts words in a file that contain a particular character")
.option("-c, --char <char>", "The character to search for", "e")

Choose a reason for hiding this comment

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

Is there a reason you added this specific counting feature? I tested it and it does not seem to work right.

Copy link
Author

Choose a reason for hiding this comment

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

You’re right, the counting feature isn’t part of cat and shouldn’t be included. I’ve removed it and focused on matching cat’s behaviour for the required flags (-n and -b) and file globbing, keeping the output identical to the real tool

globalLineCounter++;
} else if (numberNonblank) {
if (line.trim().length > 0) {
console.log(`${String(globalLineCounter).padStart(6)}\t${line} [${countInLine}]`);

Choose a reason for hiding this comment

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

You are duplicating some rather complex print formatting. is there a way to reduce this?

Copy link
Author

Choose a reason for hiding this comment

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

I extracted the line-number formatting into a helper function so the control flow only decides whether a line should be numbered, not how it’s printed. This removes duplication and makes the logic easier to follow.

Choose a reason for hiding this comment

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

good clean solution

// If multiple files, show total
if (multipleFiles) {
let output = "";
if (options.l) output += `${total.lines.toString().padStart(8)} `;

Choose a reason for hiding this comment

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

You are repeating yourself a bit on the output printing and formatting. Do you think you can improve that in any way?

Copy link
Author

Choose a reason for hiding this comment

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

I have created one function that take (lines, words, bytes), takes options and returns the formatted string
And then reuse it for each file and the total line

@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. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jan 7, 2026
@delmorallopez
Copy link
Author

I have changed the names of the scrips, they were the same names, they can get conflicts

@delmorallopez delmorallopez force-pushed the Implement-Shell-Tools branch from e617639 to 0bc2cfa Compare January 7, 2026 15:10
@delmorallopez delmorallopez added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jan 7, 2026
@LonMcGregor
Copy link

great work on this task, those updates really improve the scripts

@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 7, 2026
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. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants