diff --git a/packages/xo-cli/src/cli.js b/packages/xo-cli/src/cli.js index 6ba5a9aa8..bdb0f5001 100644 --- a/packages/xo-cli/src/cli.js +++ b/packages/xo-cli/src/cli.js @@ -44,6 +44,35 @@ var wrap = function (val) { //==================================================================== +var help = wrap((function (pkg) { + return multiline.stripIndent(function () {/* + Usage: + + $name --register [] [] [] + Registers the XO instance to use. + + $name --list-commands [--json] + Returns the list of available commands on the current XO instance. + + $name [=]... + Executes a command on the current XO instance. + + $name v$version + */}).replace(/<([^>]+)>|\$(\w+)/g, function (_, arg, key) { + if (arg) { + return '<'+ chalk.yellow(arg) +'>'; + } + + if ('name' === key) { + return chalk.bold(pkg[key]); + } + + return pkg[key]; + }); +})(require('../package'))); + +//-------------------------------------------------------------------- + exports = module.exports = function (args) { if (!args || !args.length) { return help(); @@ -66,20 +95,7 @@ exports = module.exports = function (args) { //-------------------------------------------------------------------- -var help = exports.help = wrap(multiline.stripIndent(function () {/* - Usage: - - xo-cli --register [] [] [] - Registers the XO instance to use. - - xo-cli --list-commands [--json] - Returns the list of available commands on the current XO instance. - - xo-cli [=]... - Executes a command on the current XO instance. -*/})); - -exports.version = wrap('xo-cli v'+ require('../package').version); +exports.help = help; exports.register = function (args) { var xo;