From 382d0a9b087aacdf4bc84c3d3922e00357f5c3c9 Mon Sep 17 00:00:00 2001 From: Florian Ebeling Date: Thu, 7 Dec 2023 21:51:50 +0100 Subject: [PATCH] Add sample usage banner --- .gitignore | 1 + README.md | 16 ++++++++++++++++ example.js | 28 ---------------------------- 3 files changed, 17 insertions(+), 28 deletions(-) delete mode 100644 example.js diff --git a/.gitignore b/.gitignore index 99b30da..5d087ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules TODO.md /dist +/example.js diff --git a/README.md b/README.md index cce5a5c..2011ba0 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,19 @@ if (ok) { process.exit(1); } ``` + +`synopt.usage()` genertes this usage banner. + +``` +Usage: mkwebmanifest [options] + +Generate icons and web manifest for web applications + + -i, --icon ICON source icon file + -n, --name NAME name of the web application + --config FILE configuration file + --outdir directory path for generated files + --verbose more output + -h, --help print help + +``` diff --git a/example.js b/example.js deleted file mode 100644 index e3b42f9..0000000 --- a/example.js +++ /dev/null @@ -1,28 +0,0 @@ -import synopt from "./dist/synopt.js"; - -// Declare options -synopt - .name("mkwebmanifest") // optional, for usage banner - .summary("Generate icons and web manifest for web applications") - .option("-i", "--icon ICON", "source icon file") - .option("-n", "--name", "name of the web application", { repeat: true }) - .option("--config FILE", "configuration file") - .option("--outdir ", "directory path for generated files") - .option("--verbose", "more output", { boolean: true }) - .option("-h", "--help", "print help", { boolean: true }); - -// Slice off node executable and script from argument vector -const argv = process.argv.slice(2); - -// And parse arguments. No exceptions to catch, instead check result object -const { ok, error, options } = synopt.parse(argv); - -if (ok) { - // Happy case - main(options); -} else { - // Handle errors: missing value, or unknown options/typos, etc. - console.log(error); - console.log(synopt.usage()); - process.exit(1); -} \ No newline at end of file