Skip to content

Options object is not strictly the user input #644

Closed
@elliot-nelson

Description

Take this simple program:

program
    .command('list')
    .description('lists all objects')
    .options('--name <name>', 'filter by name')
    .action(function (options) {
        // Program prints "filter enabled", even if user does not provide a value.
        console.log(options.name ? 'filter enabled' : 'filter disabled');
    })

The options object is not a raw property bag of the command line options, it is an object with some functions defined on it, one of which seems to be name, another is parent.

I feel like the API should be changed so there aren't hidden mines under certain option names -- or, at least, the documentation should make it clear what option names will conflict with these special API functions.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions