We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5d1476b commit df5b8e5Copy full SHA for df5b8e5
1 file changed
implement-shell-tools/wc/wc.py
@@ -6,6 +6,9 @@
6
description="Count lines, words, and characters"
7
)
8
parser.add_argument("paths", nargs='+', help="Files to count")
9
+parser.add_argument("-l", "--lines", action="store_true", help="Count lines only")
10
+parser.add_argument("-w", "--words", action="store_true", help="Count words only")
11
+parser.add_argument("-c", "--chars", action="store_true", help="Count characters only")
12
13
args = parser.parse_args()
14
@@ -19,4 +22,11 @@
19
22
words = len(content.split())
20
23
chars = len(content)
21
24
- print(f"{lines:8}{words:8}{chars:8} {path}")
25
+ if args.lines:
26
+ print(f"{lines:8} {path}")
27
+ elif args.words:
28
+ print(f"{words:8} {path}")
29
+ elif args.chars:
30
+ print(f"{chars:8} {path}")
31
+ else:
32
+ print(f"{lines:8}{words:8}{chars:8} {path}")
0 commit comments