diff --git a/packages/xo-cli/README.md b/packages/xo-cli/README.md index 245ee56ad..4cb12b380 100644 --- a/packages/xo-cli/README.md +++ b/packages/xo-cli/README.md @@ -105,6 +105,12 @@ encoding by prefixing with `json:`: > xo-cli foo.bar baz='json:[1, 2, 3]' ``` +##### Configuration export + +``` +> xo-cli xo.exportConfig @=config.json +``` + ##### VM export ``` diff --git a/packages/xo-cli/src/index.js b/packages/xo-cli/src/index.js index 475807e31..ed375390c 100755 --- a/packages/xo-cli/src/index.js +++ b/packages/xo-cli/src/index.js @@ -328,6 +328,15 @@ async function listObjects (args) { } exports.listObjects = listObjects +function ensurePathParam (method, value) { + if (typeof value !== 'string') { + const error = + method + + ' requires the @ parameter to be a path (e.g. @=/tmp/config.json)' + throw error + } +} + async function call (args) { if (!args.length) { throw new Error('missing command name') @@ -350,6 +359,7 @@ async function call (args) { key = keys[0] if (key === '$getFrom') { + ensurePathParam(method, file) url = resolveUrl(baseUrl, result[key]) const output = createWriteStream(file) @@ -371,6 +381,7 @@ async function call (args) { } if (key === '$sendTo') { + ensurePathParam(method, file) url = resolveUrl(baseUrl, result[key]) const stats = await stat(file)