Skip to content

Commit 38c96e9

Browse files
committed
set up argparse with -n, -n flags
1 parent a49c91e commit 38c96e9

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎implement-shell-tools/cat/cat.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import argparse
2+
3+
parser = argparse.ArgumentParser(
4+
prog="a simple cat implementation",
5+
description="cat command line tool with the -n and -b flags"
6+
)
7+
8+
parser.add_argument("-n", action="store_true", help="number all output lines")
9+
parser.add_argument("-b", action="store_true", help="number non-empty output lines")
10+
parser.add_argument("paths", nargs="+", help="file path or paths", )
11+
12+
args = parser.parse_args();
13+
14+
print(args)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
argparse

0 commit comments

Comments
 (0)