Skip to content

Commit c7449be

Browse files
committed
Parse optoins using commander
1 parent 667e3bb commit c7449be

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

implement-shell-tools/wc/package-lock.json

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "wc",
3+
"version": "1.0.0",
4+
"description": "You should already be familiar with the `wc` command line tool.",
5+
"main": "wc.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC",
12+
"type": "module",
13+
"dependencies": {
14+
"commander": "^15.0.0"
15+
}
16+
}

implement-shell-tools/wc/wc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { program } from "commander";
2+
3+
program
4+
.name("wc")
5+
.description("Mimics the wc command line tool")
6+
.option("-w")
7+
.option("-c")
8+
.option("-l");
9+
10+
program.parse();
11+
12+
const options = program.opts();
13+
14+
console.log(options);

0 commit comments

Comments
 (0)