West Midlands | 26 March SDC | Iswat Bello | Sprint 4 | implement shell tools in python#505
Conversation
- Add .venv to ignore Python virtual environments - Add *.class to ignore Java compiled class files
- Implement ls/ls.py: Python version of ls utility - Add -1/--one-per-line flag for single column output - Add -a/--all flag to show hidden files (dotfiles) - Color directories in blue using ANSI escape codes - Sort entries case-insensitively for better readability - Support custom directory path argument (default to current directory) - Add error handling with proper exit codes - Match behavior of JavaScript implementation
- Implement wc/wc.py: Python version of wc utility - Support -l/--lines, -w/--words, -c/--bytes flags - Read from stdin when no files provided - Process multiple files with totals row - Calculate byte counts using raw file bytes for accuracy - Format output with right-justified columns (4-char width) - Handle file not found errors with proper exit codes - Match behavior of JavaScript implementation - Add argparse for robust CLI argument parsing
There was a problem hiding this comment.
There was a problem hiding this comment.
Thank you for the review. I have made changes to the code.
There was a problem hiding this comment.
Thank you, the implementation looks good now.
There was a problem hiding this comment.
The implementation looks good to me.
There was a problem hiding this comment.
Suggestion: The print_formatted_report takes args as a parameter just to read flag states, this implementation couples this funciton to the CLI layer. The cleaner design is to resolve which columns to show in main() and pass a simple set or list of flags down.
There was a problem hiding this comment.
Thank you for the feedback. I have implemented your suggestion.
There was a problem hiding this comment.
Thanks, the implementation looks good to me.
- Replace read-all-then-process with line-by-line streaming - Fix -b flag: only skip truly empty lines (not whitespace-only lines) - Fix line numbering: use tabs after number to match real cat format - Maintain line number across multiple files for -n and -b flags - Improve error handling with file-specific error messages
…://github.com/Iswanna/Module-Tools into tools/sprint4/implement-shell-tools-in-python
- Replace should_show_all_stats boolean with active_flags list - Simplify print_formatted_report to accept flag list instead of args object - Increase column width from 4 to 8 for better alignment with standard wc - Remove unused os import - Simplify comments for clarity - Refactor flag resolution into straightforward list building - Improve readability of argument parser definitions
…nment - Change rjust(8) to rjust(4) in print_formatted_report - Matches real wc utility column formatting more closely - Reduces excessive whitespace in output - Update comment to reflect correct width value
behnamkvl
left a comment
There was a problem hiding this comment.
The imlementation looks good, please proceed to close the PR.
There was a problem hiding this comment.
Thanks, the implementation looks good to me.

Learners, PR Template
Self checklist
Changelist
In this PR, I implemented three core Unix shell utilities in Python:
cat,ls, andwc.cat/cat.py
-n/--numberflag: number all output lines-b/--number-nonblankflag: number only non-empty linesls/ls.py
-1/--one-per-lineflag: list one file per line-a/--allflag: show hidden files (dotfiles)wc/wc.py
-l/--linesflag: print line counts-w/--wordsflag: print word counts-c/--bytesflag: print byte counts