Merge pull request #36 from resin-io/feature/standard-version

Implement --version/-v global options. Closes #35
This commit is contained in:
Juan Cruz Viotti 2015-04-30 13:12:51 -04:00
commit 144a155208
4 changed files with 27 additions and 5 deletions

View File

@ -7,8 +7,9 @@
signature: 'version',
description: 'output the version number',
help: 'Display the Resin CLI version.',
action: function() {
return console.log(packageJSON.version);
action: function(params, options, done) {
console.log(packageJSON.version);
return done();
}
};

View File

@ -49,6 +49,13 @@
alias: 'j'
});
capitano.globalOption({
signature: 'version',
description: actions.info.version.description,
boolean: true,
alias: 'v'
});
capitano.globalOption({
signature: 'no-color',
description: 'disable colour highlighting',
@ -161,7 +168,11 @@
if (cli.global.project != null) {
changeProjectDirectory(cli.global.project);
}
return capitano.execute(cli, callback);
if (cli.global.version) {
return actions.info.version.action(null, null, callback);
} else {
return capitano.execute(cli, callback);
}
}
], errors.handle);

View File

@ -6,5 +6,6 @@ exports.version =
help: '''
Display the Resin CLI version.
'''
action: ->
action: (params, options, done) ->
console.log(packageJSON.version)
return done()

View File

@ -31,6 +31,12 @@ capitano.globalOption
description: 'project path'
alias: 'j'
capitano.globalOption
signature: 'version'
description: actions.info.version.description
boolean: true
alias: 'v'
# We don't do anything in response to this options
# explicitly. We use InquirerJS to provide CLI widgets,
# and that module understands --no-color automatically.
@ -134,6 +140,9 @@ async.waterfall([
if cli.global.project?
changeProjectDirectory(cli.global.project)
capitano.execute(cli, callback)
if cli.global.version
actions.info.version.action(null, null, callback)
else
capitano.execute(cli, callback)
], errors.handle)