Skip to content

Conversation

@ike-agu
Copy link

@ike-agu ike-agu commented Dec 12, 2025

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 contains my implementation of cat, ls and wc shell tool commands in python

@ike-agu ike-agu added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 12, 2025
@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (Sprint-4) doesn't match expected format (example: 'Sprint 2', without quotes)

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 12, 2025
@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (Sprint-4) doesn't match expected format (example: 'Sprint 2', without quotes)

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@ike-agu ike-agu changed the title London | SDC-Nov-2025 | Ikenna Agulobi | Sprint-4 | Implement shell tools python London | SDC-Nov-2025 | Ikenna Agulobi | Sprint 4 | Implement shell tools python Dec 12, 2025
@ike-agu ike-agu added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 12, 2025
@DaryaShirokova DaryaShirokova added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jan 10, 2026
Copy link

@DaryaShirokova DaryaShirokova left a comment

Choose a reason for hiding this comment

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

Looks good! Just added a few comments

python cat.py sample-files/*.txt

* Number every line across multiple files(including empty ones)
python cat.py -n sample-files/*.txt

Choose a reason for hiding this comment

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

There is a small discrepancy in how you program handles some cases it seems:

$ cat -n sample-files/*.txt
     1  Once upon a time...
     2  There was a house made of gingerbread.
     3  It looked delicious.
     4  I was tempted to take a bite of it.
     5  But this seemed like a bad idea...
     6
     7  There's more to come, though...
     
$ python cat.py -n sample-files/*.txt
1 Once upon a time...
2 
3 There was a house made of gingerbread.
4 
5 It looked delicious.
6 I was tempted to take a bite of it.
7 But this seemed like a bad idea...
8 
9 There's more to come, though...
10 

@@ -0,0 +1,50 @@
import argparse
# -------------------------------------------

Choose a reason for hiding this comment

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

It's ok to have comments, but it would be even better to have the code split into methods with descriptive names :)

Comment on lines +33 to +35
content = f.read()

lines = content.split("\n")

Choose a reason for hiding this comment

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

Maybe check if you could use readlines method here.

return args.paths

# list a single directory
def list_directory(directory_path, show_hidden, file_per_line):

Choose a reason for hiding this comment

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

It is good as is, but as a suggestion - a tiny bit cleaner approach would be to first get the list of directories/files and for list_directory function to just accept this list and print it (filtering whatever is not needed). This would follow 1 method/1 responsibility paradigm (which helps with code readability / reusability).



def main():
# --------------------------------------------------------

Choose a reason for hiding this comment

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

Again, maybe try splitting into functions instead of comment blocks instead :)

# --------------------------------------------------------
# Print totals if there are multiple files
# --------------------------------------------------------
if len(args.paths) > 1:

Choose a reason for hiding this comment

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

Maybe there is a way to reuse the same functions (with different args) for printing individual lines and totals

python wc.py sample-files/*

* Just lines
python wc.py -l sample-files/3.txt

Choose a reason for hiding this comment

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

Looks like some outputs are different?

wc sample-files/*
  1   4  20 sample-files/1.txt
  1   7  39 sample-files/2.txt
  5  24 125 sample-files/3.txt
  7  35 184 total
$ python wc.py sample-files/*
2 4 20 sample-files/1.txt
2 7 39 sample-files/2.txt
6 24 125 sample-files/3.txt
10 35 184 total

@DaryaShirokova DaryaShirokova added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jan 10, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants