Skip to content

West Midlands | 26 March SDC | Iswat Bello | Sprint 3 | implement shell tools#454

Open
Iswanna wants to merge 7 commits intoCodeYourFuture:mainfrom
Iswanna:tools/sprint3-implement-shell-tools
Open

West Midlands | 26 March SDC | Iswat Bello | Sprint 3 | implement shell tools#454
Iswanna wants to merge 7 commits intoCodeYourFuture:mainfrom
Iswanna:tools/sprint3-implement-shell-tools

Conversation

@Iswanna
Copy link
Copy Markdown

@Iswanna Iswanna commented Apr 1, 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

This PR implements the cat, ls, and wc Unix utilities in Node.js using ECMAScript Modules and Commander.js for CLI parsing.
All implementations feature asynchronous file operations, robust error handling, and aligned output formatting.

Iswanna added 7 commits March 30, 2026 21:20
Add cat/cat.js which reads a file path from argv and prints the file contents
using node fs promises and top-level await. Logs argv and path (debug output).
- Refactor to async readMultipleFiles() function
- Support reading multiple files via Promise.all
- Output concatenated file contents to stdout
- Add error handling with exit code 1 on failure
- Remove debug logging (argv, path)
- Fix markdown list formatting in README (bullets)
- Replace manual argv parsing with commander.js for robust CLI handling
- Add -n/--number flag to number all output lines
- Add -b/--number-nonblank flag to number only non-empty lines
- Refactor variable names for clarity (filePathsToRead, concatenatedContent, etc)
- Improve error handling with process.exitCode = 1
- Remove debug logging
- Add ls/ls.js: reads a directory, supports -1 (one-per-line) and -a (include dotfiles)
- Use commander for CLI flags, fs.promises.readdir for reading directories
- Add error handling and set non-zero exit code on failure
- docs(ls): normalize README bullets so example commands render correctly
- Add wc/wc.js: reads files and outputs line, word, and byte counts
- Support multiple files with totals row
- Use fs.promises.readFile for async file reading
- Add error handling for missing files with non-zero exit code
- Format output to match standard wc utility (padded columns)
- docs(wc): normalize README bullets so example commands render correctly
- Migrate from manual argv parsing to commander.js for robust flag handling
- Add support for -l (lines), -w (words), -c (bytes) flags
- Refactor calculateFileStats to return object with descriptive properties
- Rename printFormattedLine to printReport for clarity
- Improve flag detection: default to all columns when no flags provided
- Maintain totals row for multiple files
- Update error messages to match standard wc format
- Clean up JSDoc comments and code structure
- Rename parameters and variables for better descriptiveness:
  - files → filePaths
  - showAll → shouldShowAllStats
  - results → allFileStats
  - stats → fileStats
  - totals → grandTotals
  - label → displayName
  - s → stat (in reduce callbacks)
  - w → word (in filter callback)
  - output → outputColumns
  - format → formatColumn
  - printReport → printFormattedReport

- Extract inline calculations to named variables in calculateFileStats()
  - lines, words, bytes for improved readability

- Maintain all functionality and test coverage
- No behavioral changes, purely refactoring for clarity
@Iswanna Iswanna 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. Module-Tools The name of the module. labels Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Tools The name of the module. 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant