{"action":"created","issue":{"url":"https://api.github.com/repos/tj/commander.js/issues/477","labels_url":"https://api.github.com/repos/tj/commander.js/issues/477/labels{/name}","comments_url":"https://api.github.com/repos/tj/commander.js/issues/477/comments","events_url":"https://api.github.com/repos/tj/commander.js/issues/477/events","html_url":"https://github.com/tj/commander.js/issues/477","id":122274431,"number":477,"title":"Support callback for subcommand instead of different binary","user":{"login":"opatut","id":235784,"avatar_url":"https://avatars.githubusercontent.com/u/235784?v=3","gravatar_id":"","url":"https://api.github.com/users/opatut","html_url":"https://github.com/opatut","followers_url":"https://api.github.com/users/opatut/followers","following_url":"https://api.github.com/users/opatut/following{/other_user}","gists_url":"https://api.github.com/users/opatut/gists{/gist_id}","starred_url":"https://api.github.com/users/opatut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opatut/subscriptions","organizations_url":"https://api.github.com/users/opatut/orgs","repos_url":"https://api.github.com/users/opatut/repos","events_url":"https://api.github.com/users/opatut/events{/privacy}","received_events_url":"https://api.github.com/users/opatut/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-15T13:38:02Z","updated_at":"2015-12-22T00:37:20Z","closed_at":null,"body":"I'd like to structure my application myself. I'd like to supply a function that is called with the arguments instead of having to supply a binary with the correct name. My subcommands are usually one-liners, this would cut down on small files significantly for me.\r\n\r\nIn the subcommand I could \"recursively\" use the supplied args and create sub-subcommands. That'd be fun :)\r\n\r\nAlso, I'd love to have access to the \"parent\" parsed arguments when running the subcommand, so in\r\n\r\n    ./my-cli --parent-arg 42 subcommand --child-arg 1337\r\n\r\nI could fetch the `parent-arg` when the subcommand is invoked. I suggest:\r\n\r\n    function subcommandCallback(args) { // ... }\r\n\r\nWhere `args` contains the special key `_parent` with the parent command's arguments. Also, recursively."},"comment":{"url":"https://api.github.com/repos/tj/commander.js/issues/comments/166467219","html_url":"https://github.com/tj/commander.js/issues/477#issuecomment-166467219","issue_url":"https://api.github.com/repos/tj/commander.js/issues/477","id":166467219,"user":{"login":"hildjj","id":93963,"avatar_url":"https://avatars.githubusercontent.com/u/93963?v=3","gravatar_id":"","url":"https://api.github.com/users/hildjj","html_url":"https://github.com/hildjj","followers_url":"https://api.github.com/users/hildjj/followers","following_url":"https://api.github.com/users/hildjj/following{/other_user}","gists_url":"https://api.github.com/users/hildjj/gists{/gist_id}","starred_url":"https://api.github.com/users/hildjj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hildjj/subscriptions","organizations_url":"https://api.github.com/users/hildjj/orgs","repos_url":"https://api.github.com/users/hildjj/repos","events_url":"https://api.github.com/users/hildjj/events{/privacy}","received_events_url":"https://api.github.com/users/hildjj/received_events","type":"User","site_admin":false},"created_at":"2015-12-22T00:37:19Z","updated_at":"2015-12-22T00:37:19Z","body":"Look at the deploy example: https://github.com/tj/commander.js/blob/master/examples/deploy\r\n\r\nIt took me a couple of tries to parse through the documentation to understand what that example is doing.  The action for each command gets an `options` parameter that is almost exactly what you want, with a `options.parent` that contains the top-level options.  each call to `command` starts a new chain, where the options set in that chain only apply to that command -- this is why each command definition starts with `program` again."}}