diff --git a/README.md b/README.md index b0df57a..ffe10f5 100644 --- a/README.md +++ b/README.md @@ -23,22 +23,26 @@ Place the following code in your **bin/cli.js** file import { cliArgvUtil } from 'cli-argv-util'; const validFlags = ['cd', 'find', 'no-summary']; -const cli = cliArgvUtil.parse(validFlags); -if (cliArgvUtil.invalidFlag) - throw Error(cliArgvUtil.invalidFlagMsg); +const cli = cliArgvUtil.parse(validFlags); +if (cli.invalidFlag) + throw Error(cli.invalidFlagMsg); +if (cli.flagOn.find) + console.log('You set the --find CLI flag to:', cli.flagMap.find); +if (cli.flagOn.noSummary) + console.log('You enabled the --no-summary CLI option.'); +console.log('You supplied', cli.params.length , 'CLI parameter(s).'); ``` For a real world example, see: [cli.js](https://github.com/center-key/copy-file-util/blob/main/bin/cli.js) If your CLI tool is named `my-program` and a user runs it like: ```shell -$ my-program file.html --cd=src --no-summary file.png +$ my-program about.html --cd=src --no-summary 'Hello World' 777 ``` the resulting `cli` object will be: ```javascript { flagMap: { - cd: 'src', - noSummary: undefined, + cd: 'src', }, flagOn: { cd: true, @@ -47,9 +51,10 @@ the resulting `cli` object will be: }, invalidFlag: null, invalidFlagMsg: null, - params: ['file.html', 'file.png'], + params: ['about.html', 'Hello World', '777'], } ``` +_**Note:** Single quotes in commands are normalized so they work cross-platform and avoid the errors often encountered on Microsoft Windows._ ## C) Results The `cliArgvUtil.parse()` returns an object of type `Result`: diff --git a/package.json b/package.json index ce04aa6..de8767f 100644 --- a/package.json +++ b/package.json @@ -80,13 +80,13 @@ "slash": "~5.1" }, "devDependencies": { - "@types/node": "~20.6", + "@types/node": "~20.8", "@typescript-eslint/eslint-plugin": "~6.7", "@typescript-eslint/parser": "~6.7", "add-dist-header": "~1.3", "assert-deep-strict-equal": "~1.1", "copy-file-util": "~1.1", - "eslint": "~8.50", + "eslint": "~8.51", "jshint": "~2.13", "mocha": "~10.2", "rimraf": "~5.0", diff --git a/task-runner.sh.command b/task-runner.sh.command index 88bbf80..2ffd31a 100755 --- a/task-runner.sh.command +++ b/task-runner.sh.command @@ -57,7 +57,7 @@ releaseInstructions() { echo "When ready to do the next release:" echo echo " === Increment version ===" - echo " Edit pacakge.json to bump $version to next version number" + echo " Edit package.json to bump $version to next version number" echo " $projectHome/package.json" } nextActionCommitTagPub() {