Skip to content

Cannot create an error to say "too many arguments" #618

@kumar303

Description

@kumar303

I want a command with extraneous arguments to raise an error. For example:

node script.js args-not-supported

This should produce some kind of error, I guess like:

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]

Too many non-option arguments

Is this possible? I thought the following code would do it but it does not produce an error at all.

var yargs = require('yargs');
yargs
  .help('help')
  .demand(0)
  .strict()
  .argv;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions