Skip to content

Commit 2c3458f

Browse files
committed
handle no flag arguments
1 parent 45766e0 commit 2c3458f

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

  • implement-shell-tools/wc

implement-shell-tools/wc/wc.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,19 @@ program.parse();
1515
const options = program.opts();
1616
const files = program.args;
1717

18+
console.log(options);
1819
console.log(files);
20+
21+
// if no -lwc flags are supplied, wc prints
22+
// lines, words, bytes of each file
23+
// whereas if any flags are supplied only those
24+
// values are printed
25+
if (Object.keys(options).length === 0) {
26+
options.l = options.w = options.c = true;
27+
}
28+
29+
/*
30+
array of objects with data [{l: 2, w: 12: c: 123, file: 'sample-files/1.txt}, ...]
31+
For each item, create a temp string
32+
If options.l, append to temp string the w value
33+
*/

0 commit comments

Comments
 (0)