Commit 3fed2f0b63
Verified · cmc
Layout: unified · split
.gitignore added +1
| @@ -0,0 +1 @@ | |||
| 1 | python/venv\ No newline at end of file | ||
python/cat.py added +13
| @@ -0,0 +1,13 @@ | |||
| 1 | import argparse | ||
| 2 | |||
| 3 | # Create an argument parser to obtain file name | ||
| 4 | parser = argparse.ArgumentParser(description='cat') | ||
| 5 | parser.add_argument('-f', '--file', help='File name') | ||
| 6 | args = parser.parse_args() | ||
| 7 | |||
| 8 | # Open the file using the `file` argument | ||
| 9 | path = args.file | ||
| 10 | with open(path, 'r') as file: | ||
| 11 | # Read and print the file contents | ||
| 12 | contents = file.read() | ||
| 13 | print(contents) | ||