Skip to content

Option values should not be added to the command instance. #183

@badsyntax

Description

@badsyntax

Adding the option values to the command object will only cause conflicts between the properties of the command object and of the command options.

Let's take this example:

program.option('--parse', 'parse');
program.option('--parse2', 'parse');

program.parse(['node', 'test', '--parse', '--parse2']);
console.log(program.parse); // undefined
console.log(program.parse2); // true

This seems like a pretty serious bug to me, certainly it's prevented me from naming my option 'parent' because of conflicts with this particular line: https://github.com/visionmedia/commander.js/blob/master/index.js#L155

Why can't the option values just be added to a new empty object?? Something like this;

program.option('--parse', 'parse');
program.option('--parse2', 'parse');

program.parse(['node', 'test', '--parse', '--parse2']);
console.log(program.input.parse); // true
console.log(program.input.parse2); // true

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions