0

I am using the Yargs JavaScript library for parsing command-line arguments.

The following is a Hello-World-style Yargs program. By default, it includes "--help" and "--version", and I am adding a 3rd option, "--copy":

const argv = yargs(process.argv.slice(2))
  .alias("h", "help") // By default, only "--help" is enabled
  .alias("v", "version") // By default, only "--version" is enabled

  .boolean("copy")
  .alias("c", "copy")
  .describe("c", "run the copy function")

  .argv;

However, running the program with a bogus flag (e.g. "--foo") will still work. I want the program to throw an error and exit if an invalid flag is passed. How do I do this?

James
  • 1,394
  • 2
  • 21
  • 31

1 Answers1

0

Apparently this is performed using the strict mode:

https://github.com/yargs/yargs/issues/1890

James
  • 1,394
  • 2
  • 21
  • 31