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:
parent
3c7fa05c43
commit
d45f843308
@ -27,4 +27,6 @@
|
||||
|
||||
<!--packages-start-->
|
||||
|
||||
- xo-cli minor
|
||||
|
||||
<!--packages-end-->
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user