feat(xo-cli/rest): dot syntax for deep properties

`foo.bar=baz` can be used instead of `foo=json:'{ "bar": "baz" }'`.
This commit is contained in:
Julien Fontanet 2024-01-31 15:02:17 +01:00
parent 3c7fa05c43
commit d45f843308
2 changed files with 5 additions and 2 deletions

View File

@ -27,4 +27,6 @@
<!--packages-start-->
- xo-cli minor
<!--packages-end-->

View File

@ -8,6 +8,7 @@ import { readChunk } from '@vates/read-chunk'
import getopts from 'getopts'
import hrp from 'http-request-plus'
import merge from 'lodash/merge.js'
import set from 'lodash/set.js'
import split2 from 'split2'
import * as config from './config.mjs'
@ -29,10 +30,10 @@ function parseParams(args) {
for (const arg of args) {
const i = arg.indexOf('=')
if (i === -1) {
params[arg] = ''
set(params, arg, '')
} else {
const value = arg.slice(i + 1)
params[arg.slice(0, i)] = value.startsWith('json:') ? JSON.parse(value.slice(5)) : value
set(params, arg.slice(0, i), value.startsWith('json:') ? JSON.parse(value.slice(5)) : value)
}
}
return params