{"action":"created","issue":{"url":"https://api.github.com/repos/tj/commander.js/issues/331","labels_url":"https://api.github.com/repos/tj/commander.js/issues/331/labels{/name}","comments_url":"https://api.github.com/repos/tj/commander.js/issues/331/comments","events_url":"https://api.github.com/repos/tj/commander.js/issues/331/events","html_url":"https://github.com/tj/commander.js/issues/331","id":54612450,"number":331,"title":".action is broken; README gives incorrect instructions for .action","user":{"login":"StoneCypher","id":77482,"avatar_url":"https://avatars.githubusercontent.com/u/77482?v=3","gravatar_id":"","url":"https://api.github.com/users/StoneCypher","html_url":"https://github.com/StoneCypher","followers_url":"https://api.github.com/users/StoneCypher/followers","following_url":"https://api.github.com/users/StoneCypher/following{/other_user}","gists_url":"https://api.github.com/users/StoneCypher/gists{/gist_id}","starred_url":"https://api.github.com/users/StoneCypher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StoneCypher/subscriptions","organizations_url":"https://api.github.com/users/StoneCypher/orgs","repos_url":"https://api.github.com/users/StoneCypher/repos","events_url":"https://api.github.com/users/StoneCypher/events{/privacy}","received_events_url":"https://api.github.com/users/StoneCypher/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-16T19:07:48Z","updated_at":"2015-01-16T23:25:11Z","closed_at":"2015-01-16T23:00:33Z","body":"There are instructions for `.action` in the README.  Those instructions are incorrect.  If you copy pasta the example code, your instance will fail a la #285.\r\n\r\nHowever, if you imitate [the test](https://github.com/tj/commander.js/blob/master/test/test.command.action.js) and add both a `.command` and a `.option` first, the app can run - with incorrect results.\r\n\r\nGiven the code\r\n\r\n```javascript\r\nvar Commander = require(\"commander\"),\r\n\r\n    Package   = require(\"./package.json\"),\r\n    lib       = path.join( path.dirname( fs.realpathSync(__filename) ), \"rlode.js\" );\r\n\r\nCommander\r\n    .version(Package.version)\r\n    .command('rlode [options] <glob ...>')\r\n    .option('-g, --glob', 'specify glob to match against')\r\n    .action(function(cmd, opts) {\r\n        console.log(JSON.stringify([ \"finder\", cmd, opts ]));\r\n    });\r\n\r\nCommander.parse(process.argv);\r\n```\r\n\r\nNo apparent command will actually trigger that action, however, and neither `-g` nor `--glob` are recognized.\r\n\r\n```\r\nJohns-MacBook-Pro:ReverseLodestone johnh$ rlode\r\n[]\r\nJohns-MacBook-Pro:ReverseLodestone johnh$ rlode myglob\r\n[]\r\nJohns-MacBook-Pro:ReverseLodestone johnh$ rlode -g myglob\r\n\r\n  error: unknown option `-g'\r\n\r\nJohns-MacBook-Pro:ReverseLodestone johnh$ rlode --glob myglob\r\n\r\n  error: unknown option `--glob'\r\n```\r\n\r\nAlso, the help text is badly broken.  `[options]` occurs twice, `<glob ...>` is incorrectly trimmed, and there's a stray `undefined` at the end.\r\n\r\n```\r\nJohns-MacBook-Pro:ReverseLodestone johnh$ rlode --help\r\n\r\n  Usage: rlode [options] [command]\r\n\r\n\r\n  Commands:\r\n\r\n    rlode [options] [options] <glo>  undefined\r\n\r\n  Options:\r\n\r\n    -h, --help     output usage information\r\n    -V, --version  output the version number\r\n```\r\n\r\nIt is not clear whether this requirement is intentional.  I recommend against this requirement; it is unnecessary and cumbersome."},"comment":{"url":"https://api.github.com/repos/tj/commander.js/issues/comments/70339153","html_url":"https://github.com/tj/commander.js/issues/331#issuecomment-70339153","issue_url":"https://api.github.com/repos/tj/commander.js/issues/331","id":70339153,"user":{"login":"StoneCypher","id":77482,"avatar_url":"https://avatars.githubusercontent.com/u/77482?v=3","gravatar_id":"","url":"https://api.github.com/users/StoneCypher","html_url":"https://github.com/StoneCypher","followers_url":"https://api.github.com/users/StoneCypher/followers","following_url":"https://api.github.com/users/StoneCypher/following{/other_user}","gists_url":"https://api.github.com/users/StoneCypher/gists{/gist_id}","starred_url":"https://api.github.com/users/StoneCypher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StoneCypher/subscriptions","organizations_url":"https://api.github.com/users/StoneCypher/orgs","repos_url":"https://api.github.com/users/StoneCypher/repos","events_url":"https://api.github.com/users/StoneCypher/events{/privacy}","received_events_url":"https://api.github.com/users/StoneCypher/received_events","type":"User","site_admin":false},"created_at":"2015-01-16T23:25:11Z","updated_at":"2015-01-16T23:25:11Z","body":"@SomeKittens I did comment there before I opened this, and this is not a dupe of #285.\r\n\r\nPlease re-open."}}