Merge pull request #376 from resin-io/feature/global-help-option

Add global --help option
This commit is contained in:
Juan Cruz Viotti 2016-07-31 20:41:28 -04:00 committed by GitHub
commit d81fbad6f3
2 changed files with 19 additions and 0 deletions

View File

@ -53,6 +53,12 @@ limitations under the License.
}
});
capitano.globalOption({
signature: 'help',
boolean: true,
alias: 'h'
});
capitano.command(actions.info.version);
capitano.command(actions.help.help);
@ -143,6 +149,12 @@ limitations under the License.
var cli;
cli = capitano.parse(process.argv);
return events.trackCommand(cli).then(function() {
var ref, ref1;
if ((ref = cli.global) != null ? ref.help : void 0) {
return capitano.executeAsync({
command: "help " + ((ref1 = cli.command) != null ? ref1 : '')
});
}
return capitano.executeAsync(cli);
});
})["catch"](errors.handle);

View File

@ -41,6 +41,11 @@ capitano.command
action: ->
capitano.execute(command: 'help')
capitano.globalOption
signature: 'help'
boolean: true
alias: 'h'
# ---------- Info Module ----------
capitano.command(actions.info.version)
@ -119,6 +124,8 @@ plugins.register(/^resin-plugin-(.+)$/).then ->
cli = capitano.parse(process.argv)
events.trackCommand(cli).then ->
if cli.global?.help
return capitano.executeAsync(command: "help #{cli.command ? ''}")
capitano.executeAsync(cli)
.catch(errors.handle)