Various updates.

This commit is contained in:
Julien Fontanet 2014-04-03 10:19:31 +02:00
parent 8b65a75235
commit 29398b9869
5 changed files with 44 additions and 12 deletions

View File

@ -1,11 +1,22 @@
{ {
"name": "xo-cli", "name": "xo-cli",
"version": "0.1.1", "version": "0.1.1",
"license": "AGPL3",
"description": "Basic CLI for Xen-Orchestra", "description": "Basic CLI for Xen-Orchestra",
"author": "Julien Fontanet <julien.fontanet@vates.fr>", "keywords": [
"xo",
"xen-orchestra",
"xen",
"orchestra"
],
"homepage": "https://github.com/vatesfr/xo-cli", "homepage": "https://github.com/vatesfr/xo-cli",
"bugs": { "bugs": "https://github.com/vatesfr/xo-cli/issues",
"url": "https://github.com/vatesfr/xo-cli" "author": "Julien Fontanet <julien.fontanet@vates.fr>",
"preferGlobal": true,
"main": "./src/cli.js",
"directories": {
"bin": "./bin",
"man": "./man"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -24,16 +35,11 @@
}, },
"devDependencies": { "devDependencies": {
"chai": "^1.9.0", "chai": "^1.9.0",
"human-format": "^0.1.0",
"mocha": "^1.18.0", "mocha": "^1.18.0",
"mocha-promise": "0.0.1" "mocha-promise": "0.0.1"
}, },
"scripts": { "scripts": {
"test": "mocha cli.spec.js" "test": "mocha cli.spec.js"
}, }
"main": "cli.js",
"bin": {
"xo-cli": "bin/xo-cli"
},
"preferGlobal": true,
"license": "AGPL3"
} }

View File

@ -76,7 +76,7 @@ module.exports = function (argv) {
{ {
prompts.push({ prompts.push({
name: name, name: name,
message: def.prompt || def.description, message: def.prompt || def.description || name,
type: def.promptType || 'input', type: def.promptType || 'input',
}); });
} }
@ -167,6 +167,23 @@ module.exports = function (argv) {
}).bind(); }).bind();
}); });
registerCommand('list-commands', {}, function () {
return connect().then(function (xo) {
return xo.send('system.listMethods').then(JSON.stringify);
});
});
registerCommand('show-command', {
args: {
name: {
required: true,
},
},
}, function (opts) {
return connect().then(function (xo) {
return xo.send('system.methodSignature', {name: opts.name}).then(console.log);
});
});
registerCommand('whoami', { registerCommand('whoami', {
description: 'displays information about the current user', description: 'displays information about the current user',
}, function () { }, function () {
@ -186,7 +203,16 @@ module.exports = function (argv) {
}); });
// TODO: handle global `--config FILE` option. // TODO: handle global `--config FILE` option.
nomnom.parse(argv); nomnom
.option('version', {
flag: true,
help: 'prints the current version of xo-cli',
callback: function () {
return 'xo-cli version '+ require('../package').version;
},
})
.parse(argv)
;
// Executes the selected command. // Executes the selected command.
Promise.try(command, [commandOpts]).then(function (value) { Promise.try(command, [commandOpts]).then(function (value) {