From a70e38ef1209cd1bd721f8c36de59181810a08c9 Mon Sep 17 00:00:00 2001 From: Kostas Lekkas Date: Fri, 29 Jul 2016 15:32:12 +0300 Subject: [PATCH] Add global --help option --- build/app.js | 12 ++++++++++++ lib/app.coffee | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/build/app.js b/build/app.js index 0da7595f..cb58bf90 100644 --- a/build/app.js +++ b/build/app.js @@ -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); diff --git a/lib/app.coffee b/lib/app.coffee index d7a30d87..a31c9870 100644 --- a/lib/app.coffee +++ b/lib/app.coffee @@ -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)