Skip to content

Extra arguments : document and add configuration to fail if they exist #1268

@Lectem

Description

@Lectem

By default it seems that any extra argument will be available in an array after the command object.

The issue comes from the fact that it is not a documented behavior, and if the callback does not have this additional array parameter, it will silently be executed.

While this can be useful if you want to parse those extra arguments yourself, I think the default should be to error out when some arguments are not parsed (or at least, give it as an config option).

Right now, one must do the following:

.command('somecommand <filePath>')
.action((filePath, cmdObj, additionalArgs) => {
        if (additionalArgs && additionalArgs.length > 0)
        {
            cmdObj.help();
        }
        // ...
});

It would be nice if something like this could have the same effect:

.command('somecommand <filePath>')
.noExtraArgs(true)
.action((filePath) => {
        // ...
});

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions