Commands filtering.
This commit is contained in:
parent
d58add18fc
commit
0f03208aa1
@ -22,9 +22,11 @@ Usage:
|
|||||||
xo-cli --register [<XO-Server URL>] [<username>] [<password>]
|
xo-cli --register [<XO-Server URL>] [<username>] [<password>]
|
||||||
Registers the XO instance to use.
|
Registers the XO instance to use.
|
||||||
|
|
||||||
xo-cli --list-commands [--json]
|
xo-cli --list-commands [--json] [<pattern>]...
|
||||||
Returns the list of available commands on the current XO instance.
|
Returns the list of available commands on the current XO instance.
|
||||||
|
|
||||||
|
The patterns can be used to filter on command names.
|
||||||
|
|
||||||
xo-cli --list-objects [<property>=<value>]...
|
xo-cli --list-objects [<property>=<value>]...
|
||||||
Returns a list of XO objects.
|
Returns a list of XO objects.
|
||||||
|
|
||||||
@ -62,6 +64,12 @@ all VM templates:
|
|||||||
> xo-cli --list-commands
|
> xo-cli --list-commands
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Commands can be filtered using patterns:
|
||||||
|
|
||||||
|
```
|
||||||
|
> xo-cli --list-commands '{user,group}.*'
|
||||||
|
```
|
||||||
|
|
||||||
#### Execute a command
|
#### Execute a command
|
||||||
|
|
||||||
The same syntax is used for all commands: `xo-cli <command> <param
|
The same syntax is used for all commands: `xo-cli <command> <param
|
||||||
|
@ -18,9 +18,11 @@ var getKeys = require('lodash.keys')
|
|||||||
var got = require('got')
|
var got = require('got')
|
||||||
var humanFormat = require('human-format')
|
var humanFormat = require('human-format')
|
||||||
var isObject = require('lodash.isobject')
|
var isObject = require('lodash.isobject')
|
||||||
|
var micromatch = require('micromatch')
|
||||||
var multiline = require('multiline')
|
var multiline = require('multiline')
|
||||||
var nicePipe = require('nice-pipe')
|
var nicePipe = require('nice-pipe')
|
||||||
var pairs = require('lodash.pairs')
|
var pairs = require('lodash.pairs')
|
||||||
|
var pick = require('lodash.pick')
|
||||||
var prettyMs = require('pretty-ms')
|
var prettyMs = require('pretty-ms')
|
||||||
var progressStream = require('progress-stream')
|
var progressStream = require('progress-stream')
|
||||||
var Xo = require('xo-lib').Xo
|
var Xo = require('xo-lib').Xo
|
||||||
@ -114,9 +116,11 @@ var help = wrap((function (pkg) {
|
|||||||
$name --register [<XO-Server URL>] [<username>] [<password>]
|
$name --register [<XO-Server URL>] [<username>] [<password>]
|
||||||
Registers the XO instance to use.
|
Registers the XO instance to use.
|
||||||
|
|
||||||
$name --list-commands [--json]
|
$name --list-commands [--json] [<pattern>]...
|
||||||
Returns the list of available commands on the current XO instance.
|
Returns the list of available commands on the current XO instance.
|
||||||
|
|
||||||
|
The patterns can be used to filter on command names.
|
||||||
|
|
||||||
$name --list-objects [<property>=<value>]...
|
$name --list-objects [<property>=<value>]...
|
||||||
Returns a list of XO objects.
|
Returns a list of XO objects.
|
||||||
|
|
||||||
@ -197,7 +201,21 @@ function listCommands (args) {
|
|||||||
return connect().then(function getMethodsInfo (xo) {
|
return connect().then(function getMethodsInfo (xo) {
|
||||||
return xo.call('system.getMethodsInfo')
|
return xo.call('system.getMethodsInfo')
|
||||||
}).then(function formatMethodsInfo (methods) {
|
}).then(function formatMethodsInfo (methods) {
|
||||||
if (args.indexOf('--json') !== -1) {
|
var json = false
|
||||||
|
var patterns = []
|
||||||
|
forEach(args, function (arg) {
|
||||||
|
if (arg === -'--json') {
|
||||||
|
json = true
|
||||||
|
}
|
||||||
|
|
||||||
|
patterns.push(arg)
|
||||||
|
})
|
||||||
|
|
||||||
|
if (patterns.length) {
|
||||||
|
methods = pick(methods, micromatch(Object.keys(methods), patterns))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json) {
|
||||||
return methods
|
return methods
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
"lodash.isobject": "^3.0.2",
|
"lodash.isobject": "^3.0.2",
|
||||||
"lodash.keys": "^3.1.2",
|
"lodash.keys": "^3.1.2",
|
||||||
"lodash.pairs": "^3.0.1",
|
"lodash.pairs": "^3.0.1",
|
||||||
|
"lodash.pick": "^3.1.0",
|
||||||
|
"micromatch": "^2.2.0",
|
||||||
"mkdirp": "^0.5.0",
|
"mkdirp": "^0.5.0",
|
||||||
"multiline": "^1.0.2",
|
"multiline": "^1.0.2",
|
||||||
"nice-pipe": "0.0.0",
|
"nice-pipe": "0.0.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user