Skip to content

Conversation

@aydaeslami
Copy link

  • 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

Changelist

This PR includes my solutions to simulate several shell tools.
I used the Commander module to re-implement them.

@aydaeslami aydaeslami added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 25, 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 start on these tasks, i've left some pointers.

Also, as a general note, we try to be consistent in how we structure our projects and files. Can you spot the difference between how you've named your files in cat, ls, and wc?

Choose a reason for hiding this comment

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

Good solution, but consider how the numbers will display if you had longer files. Is there some formatting you could add to improve it?

continue;
}

if (opts["1"]) {

Choose a reason for hiding this comment

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

Does this function correctly?

const content = await fs.readFile(file, "utf-8");

totalChars += content.trim().length;
// const charList = content.trim().split(/\s+/);

Choose a reason for hiding this comment

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

Remember we try to avoid comitting commented out code that is no longer needed

Choose a reason for hiding this comment

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

This solution works, but it is a bit non-standard compared to the original wc implementation.

Notably, this utility is just about getting statistics, so you don't need to output the files content. That is what cat is for. Could you take another look at this one?

@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 23, 2025
Copy link

@eliza-an eliza-an 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, just a few notes as I mentioned. Leon added some as well as i saw!

lineNumber++;
}
} else if (opts.b) {
const lines = content.split("\n");

Choose a reason for hiding this comment

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

this can be exported to the outer loop as this line repetition is unnecessary ( line 22 also)

@@ -0,0 +1,40 @@
import { program } from "commander";
import { promises as fs } from "node:fs";
import process from "node:process";

Choose a reason for hiding this comment

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

i don't think this import is ever used

@@ -0,0 +1,36 @@
import { program } from "commander";
import { promises as fs } from "node:fs";
import process from "node:process";

Choose a reason for hiding this comment

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

here the import is also never used

.description("my ls clone")
.option("-1", "one entry per line")
.option("-a", "show hidden files")
.argument("[paths...]", "file or directory paths");

Choose a reason for hiding this comment

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

good use of an optional parameter here!

}

for (const path of paths) {
const entries = await fs.readdir(path);

Choose a reason for hiding this comment

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

Not a huge fan of the name entreis here. Would one of your peers marking this know exactly what you are talkign about? Try to use a bit clearer naming patters :)

@@ -0,0 +1,68 @@
import { program } from "commander";
import { promises as fs } from "node:fs";
import process from "node:process";

Choose a reason for hiding this comment

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

also unnecessary import here. Can you have a google why?


program
.name("myLs")
.description("my ls clone")

Choose a reason for hiding this comment

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

this description is incorrect

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

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants