Skip to content

Anastasiia Hlushkova | Oct2025-1 | Module-Tools | Sprint-4 | Implement-shell-tools-in-Python - #7

Open
ksbn wants to merge 5 commits into
mainfrom
implement-tasks
Open

Anastasiia Hlushkova | Oct2025-1 | Module-Tools | Sprint-4 | Implement-shell-tools-in-Python#7
ksbn wants to merge 5 commits into
mainfrom
implement-tasks

Conversation

@ksbn

@ksbn ksbn commented Apr 15, 2026

Copy link
Copy Markdown
Owner

Implement shell tools in Python

This PR implements the following shell tools in Python:

cat

  • Outputs file contents for one or multiple files
  • -n flag: numbers all lines, resetting per file
  • -b flag: numbers non-empty lines only

ls

  • -1 flag: lists files one per line
  • -a flag: includes hidden files and ./.. entries

wc

  • Counts lines, words, and bytes for one or multiple files
  • -l flag: line count
  • -w flag: word count
  • -c flag: byte count
  • Shows totals when multiple files are provided

All tools match the output and formatting of their real shell equivalents.


parser = argparse.ArgumentParser(prog='ls')
parser.add_argument('directory', nargs='?', default='.')
parser.add_argument('-1', action='store_true', dest='one')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It doesn't look like this argument is used.

@johncowie

Copy link
Copy Markdown

Overall looks good. Just a point on the ls tool and the -1 argument.

Even though these are relatively small scripts, I think it's a good exercise to think about how you might go about writing tests for these. In a professional context you'd want to have a test suite so that if you were to continue expanding these tools with support for additional options, then you can ensure that you don't break existing behaviour as the complexity increases.

That's something I can help you with if you're interested, or I could write up an example of how I would go about testing it.

@ksbn

ksbn commented Apr 26, 2026

Copy link
Copy Markdown
Owner Author

Overall looks good. Just a point on the ls tool and the -1 argument.

Even though these are relatively small scripts, I think it's a good exercise to think about how you might go about writing tests for these. In a professional context you'd want to have a test suite so that if you were to continue expanding these tools with support for additional options, then you can ensure that you don't break existing behaviour as the complexity increases.

That's something I can help you with if you're interested, or I could write up an example of how I would go about testing it.

Thank you for the feedback! I will fix the unused -1 flag in ls.py.

I'm still in my learning journey so seeing a real example of how you'd approach testing these tools would be really valuable.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants