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

Breaks when using "domain" as an option #370

Closed
mgartner opened this issue Mar 12, 2015 · 10 comments
Closed

Breaks when using "domain" as an option #370

mgartner opened this issue Mar 12, 2015 · 10 comments

Comments

@mgartner
Copy link

program
  .option('-d, --domain <domain>', 'domain name', 'example.com')
  .parse(process.argv);
events.js:86
    this.domain.enter();
                ^
TypeError: Object example.com has no method 'enter'
    at Command.emit (events.js:86:17)
    at Command.parseOptions (/Users/marcus/delstat/node_modules/commander/index.js:647:14)
    at Command.parse (/Users/marcus/delstat/node_modules/commander/index.js:435:21)
    at Object.<anonymous> (/Users/marcus/delstat/delstat.js:22:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
@SomeKittens
Copy link
Collaborator

Can you provide the full example?

@mgartner
Copy link
Author

// test.js
'use strict';

var program = require('commander');

program
  .option('-d, --domain <domain>', 'domain name', 'example.com')
  .parse(process.argv);

console.log(program.domain);
$ node test.js -d github.com

events.js:86
    this.domain.enter();
                ^
TypeError: Object example.com has no method 'enter'
    at Command.emit (events.js:86:17)
    at Command.parseOptions (/Users/marcus/commander-test/node_modules/commander/index.js:647:14)
    at Command.parse (/Users/marcus/commander-test/node_modules/commander/index.js:435:21)
    at Object.<anonymous> (/Users/marcus/commander-test/test.js:7:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)

@hildjj
Copy link

hildjj commented Aug 28, 2015

I just ran into this too. Version 2.8.1.

@zhiyelee
Copy link
Collaborator

yep. That's a problem, hope can fix it in v3.0, cause it will be a break change.
#404 (comment)

thanks @tonylukasavage for providing the list

@benjamine
Copy link

+1

@ilyache
Copy link

ilyache commented Oct 12, 2017

+1 (still an issue in 2.11.0)

@wolfgang42
Copy link

+1, duplicate of #105.

Barring a 3.0 release, maybe trying to use config.option('--domain') should at least raise an error explaining the problem and offering some workaround?

@shadowspawn
Copy link
Collaborator

The domain issue in particular is fixed in node 10.

@shadowspawn
Copy link
Collaborator

Closing this as covered by #183 and #933

@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

8 participants