Skip to content

Commit a082839

Browse files
committed
define program meta data: name, description, options, arguments/paths etc
1 parent 82424f0 commit a082839

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • implement-shell-tools/wc

implement-shell-tools/wc/wc.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,17 @@
8888
# console.log(`${totalLines} ${totalWords} ${totalCharacters} total`);
8989
# }
9090
# }
91+
92+
import argparse
93+
94+
parser = argparse.ArgumentParser(
95+
prog="counter",
96+
description="Counts lines, words or characters in a file (or all files) inside a directory",
97+
)
98+
99+
parser.add_argument("-l", "--line", dest="line", help="The number of lines in each file", action="store_true")
100+
parser.add_argument("-w", "---word", dest="word", help="The number of words in each file", action="store_true")
101+
parser.add_argument("-c", "--char", dest="char", help="The number of characters in each file")
102+
parser.add_argument("paths", help="The file(s)/path(s) to read from", nargs="+")
103+
104+
args = parser.parse_args()

0 commit comments

Comments
 (0)