Skip to content

Birmingham | 26-JUL-SDC | Merve Reis | Sprint 3 | Sheel Tools - #614

Open
mervereis wants to merge 2 commits into
CodeYourFuture:mainfrom
mervereis:implement-shell-tools
Open

Birmingham | 26-JUL-SDC | Merve Reis | Sprint 3 | Sheel Tools#614
mervereis wants to merge 2 commits into
CodeYourFuture:mainfrom
mervereis:implement-shell-tools

Conversation

@mervereis

@mervereis mervereis commented Jul 27, 2026

Copy link
Copy Markdown

… features

Learners, PR Template

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

Completed all the tasks.

Task ID: CYF-1150

@github-actions

This comment has been minimized.

@mervereis mervereis added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 27, 2026
@LonMcGregor LonMcGregor added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Aug 4, 2026

@LonMcGregor LonMcGregor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good start but there is still a lot to do here.

Is your way of handling options/arguments the best? Is there a better way of doing this?


if (numberNonBlank) {
if (line.trim() === "") {
process.stdout.write(output);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When I am looking at the output of blank lines I get some odd formatting, do you see this in your testing?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, I found the formatting issue in my testing. It was caused by the trailing newline being treated as an additional blank line. I fixed it so blank lines are handled correctly, and the output now matches the standard cat command. @LonMcGregor

}
}

if (!onePerLine) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is this last empty log doing?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It adds the final newline after the filenames have been written with process.stdout.write(), which does not add one automatically. The !onePerLine condition ensures this only happens in the default format, where filenames are displayed on the same line. @LonMcGregor

Comment thread implement-shell-tools/wc/wc.js Outdated

if (filesCounted > 1) {
let result = "";
if (countLines) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This printing code looks to be repeated, do you think you could reduce the duplication somehow?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, I reduced the duplication by moving the repeated output-building logic into a shared formatResult() function. Both the individual file results and the final total result now use this function, keeping the formatting consistent and easier to maintain. @LonMcGregor

Comment thread implement-shell-tools/wc/wc.js Outdated
}
result += "total";

console.log(result);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When you have multiple files, is the output formatting as good as it could be? How could it be made neater?

@mervereis mervereis Aug 27, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The output could be neater. The numeric values should be right-aligned in consistent columns, matching the standard wc format. I updated the formatting so both individual file results and the total row use aligned columns, making the output easier to read. @LonMcGregor

@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 Aug 4, 2026
@mervereis mervereis added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants