diff --git a/cli.ts b/cli.ts index aeead4c..0958a7d 100644 --- a/cli.ts +++ b/cli.ts @@ -1,8 +1,13 @@ import { parseArgs } from "./deps.ts"; -import { options } from "./src/const.ts"; +import { options, USAGE } from "./src/const.ts"; import { sweetid } from "./src/main.ts"; -const { count, size } = parseArgs(Deno.args, options); +const { count, size, help } = parseArgs(Deno.args, options); + +if (help) { + console.log(USAGE); + Deno.exit(); +} for (let i = count; i > 0; i--) { console.log(sweetid(size)); diff --git a/src/const.ts b/src/const.ts index 09c6878..4e22a8a 100644 --- a/src/const.ts +++ b/src/const.ts @@ -29,6 +29,8 @@ export const CharSets = { } as const; export const options: ParseOptions = { + boolean: ['help'], + alias: { count: "c", size: "s", @@ -38,4 +40,13 @@ export const options: ParseOptions = { count: 1, size: "xshort", }, + + unknown: () => { + console.log(USAGE); + Deno.exit(1); + } }; + +export const USAGE = ` +See https://deno.land/x/sweetid for details. +`;