Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options object is not strictly the user input #644

Closed
elliot-nelson opened this issue Jun 20, 2017 · 2 comments
Closed

Options object is not strictly the user input #644

elliot-nelson opened this issue Jun 20, 2017 · 2 comments

Comments

@elliot-nelson
Copy link

elliot-nelson commented Jun 20, 2017

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.

@shadowspawn
Copy link
Collaborator

This is an area we want to improve, and will be a breaking change. I have referenced this issue as one of a number of related issues.

This issue has not had any activity in over six months. It isn't likely to get acted on due to this report.

Feel free to open a new issue if it comes up again, with new information and renewed interest.

Thank you for your contributions.

@shadowspawn
Copy link
Collaborator

shadowspawn commented Nov 23, 2019

I have opened a Pull Request which allows storing option values separately rather than as command properties (access using .opts()), and passes the options (rather than the command) to the action handler.

See #1102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants