Skip to content

Commit

Permalink
Show an error and help if a CLI command is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
darekkay committed Oct 31, 2019
1 parent 18b4b4d commit 2c7bbef
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin/static-marks.js
Expand Up @@ -10,7 +10,7 @@ const importBookmarks = require("./import");

program
.description(pkg.description)
.usage("[options] <command>")
.usage("<command> [options]")
.version(pkg.version);

// build
Expand Down Expand Up @@ -44,6 +44,11 @@ program

program.parse(process.argv);

if (program.args.length === 0) {
// eslint-disable-next-line no-underscore-dangle
const commands = program.args.filter(argument => argument._name);

// missing/unknown subcommand
if (program.args.length === 0 || commands.length === 0) {
console.error(`Error: Missing or unknown command.\n`);
program.help();
}

0 comments on commit 2c7bbef

Please sign in to comment.