77 . name ( "wc" )
88 . description ( "An alternative to the 'wc' command" )
99 . argument ( "<files...>" , "The file(s) to count lines/words/bytes" )
10- . option ( "-l" , " --lines", "Print the newline counts" )
11- . option ( "-w" , " --words", "Print the word counts" )
12- . option ( "-c" , " --bytes", "Print the byte counts" )
10+ . option ( "-l, --lines" , "Print the newline counts" )
11+ . option ( "-w, --words" , "Print the word counts" )
12+ . option ( "-c, --bytes" , "Print the byte counts" )
1313 . action ( async ( files , options ) => {
1414 try {
1515 // call newWc for all files
@@ -32,20 +32,20 @@ function formatCount(count) {
3232function printWcOutput ( lineCount , wordCount , byteCount , file , options , noFlags ) {
3333 const parts = [ ] ;
3434
35- if ( noFlags || options . l ) parts . push ( formatCount ( lineCount ) ) ;
36- if ( noFlags || options . w ) parts . push ( formatCount ( wordCount ) ) ;
37- if ( noFlags || options . c ) parts . push ( formatCount ( byteCount ) ) ;
38-
35+ if ( noFlags || options . lines ) parts . push ( formatCount ( lineCount ) ) ;
36+ if ( noFlags || options . words ) parts . push ( formatCount ( wordCount ) ) ;
37+ if ( noFlags || options . bytes ) parts . push ( formatCount ( byteCount ) ) ;
38+
3939 parts . push ( file ) ;
4040 console . log ( parts . join ( " " ) ) ;
4141}
4242
4343async function newWc ( files , options ) {
4444
4545 const noFlags =
46- ! options . l &&
47- ! options . w &&
48- ! options . c ;
46+ ! options . lines &&
47+ ! options . words &&
48+ ! options . bytes ;
4949
5050 // set the counts variables
5151 let totalLines = 0 ;
0 commit comments