Skip to content

Sheffield | 2026-MAR-SDC | Jak Rhodes-Smith | Sprint 3 | Implement shell tools#366

Open
jakr-s wants to merge 11 commits into
CodeYourFuture:mainfrom
jakr-s:implement-shell-tools
Open

Sheffield | 2026-MAR-SDC | Jak Rhodes-Smith | Sprint 3 | Implement shell tools#366
jakr-s wants to merge 11 commits into
CodeYourFuture:mainfrom
jakr-s:implement-shell-tools

Conversation

@jakr-s
Copy link
Copy Markdown

@jakr-s jakr-s commented Mar 13, 2026

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

Changelist

Complete all NodeJS tool implementations

@jakr-s jakr-s added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 13, 2026
@Poonam-raj Poonam-raj added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 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 May 11, 2026
const isBlank = line.trim() === "";
const shouldNumber = options.n || (options.b && !isBlank);

console.log(shouldNumber ? `${lineNum} ${line}` : line);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

To match the cat output accurately you would need to add the correct padding instead of just spaces. Here it's meant to be padding of 6 so the output is right-aligned.

Comment on lines +32 to +33
} finally {
await file.close();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice use of finally to close the file after reading


try {
let filePaths = program.args;
if (!filePaths || filePaths.length === 0) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would argue !filePaths is a bad path you weren't asked to account for


const formatEntries = (files) => {
if (files.length === 0) return;
console.log(files.join(onePerLine ? "\n" : "\t"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In the examples you've been asked to accommodate, there is always a newline option (-1) so the onePerLine check could be seen as unnecessary. (I'd argue you could've assumed onePerLine across this solution but I am treating this as a stretch behaviour to have it optional)

I agree the use of \t is an easier fix to calculating the column padding needed, but maybe less accurate to the real ls output columns.


const filterHidden = (files) => files.filter((file) => !file.startsWith("."));

const getVisibleEntries = (files) =>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I personally dislike having a function like getVisibleEntries be dependent on a variable outside of this function. I'd prefer you to pass in includeHidden

It breaks the idea of "purity" (a function's output depends solely on arguments passed in or internal logic, no external dependencies - which includeHidden is a hidden dependency). It makes it hard to test (we need dependencies more loosely coupled), and harder to reuse

let entries = [...result.files];

for (const [dir, contents] of Object.entries(result.dirs)) {
const filtered = getVisibleEntries(contents);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(based on previous comment) we can see here how getVisibleEntries leaves a lot of questions - how is it determining what is visible or not? Is this a hard coded process, or is it a changeable output?

formatEntries(result.files);

for (const [dir, contents] of Object.entries(result.dirs)) {
console.log("\n" + dir + ":");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Small bug here - you're baking into your output a newline on the first line of prints - not an expected behaviour, the first line should be at the top with no newline

How can you separate out the concern so the newline gaps are between directory sections only and the top section doesn't have a newline before it?

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

Labels

Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants