yves-cli
v1.1.1
Published
CLI JSON inspector with jorisroling/yves.js
Maintainers
Readme
yves-cli
CLI JSON inspector with yves from Joris Röling. Pretty colors!
Install
$ npm install -g yves-cliUsage
$ yves --help
Usage: yves [options] [files...]
Options:
-V, --version output the version number
--no-pretty no pretty formatting
--no-color no color
-m, --max-length <n> max length
-r, --root <path> set dot notated root field
-f, --fields <fields> comma separated fields
-q, --query <expr> query data with expr (ala mongo)
--no-json disable JSON output
-h, --help display help for commandExamples
Sources
From file:
$ ls
package.json component.json
$ yves package.jsonOr many files:
$ ls
package.json component.json
$ yves package.json component.jsonPipe from any source:
$ curl -s "https://api.github.com/users/jorisroling" | yves$ echo '{"foo": {"bar": 0}}' | yves
{
"foo": { "bar": 0 }
}Output is JSON by default. Use --no-json for yves-style formatting:
$ echo '{"foo": {"bar": 0}}' | yves --no-json
{
foo: { bar: 0 }
}Navigate with --root
Use dot notation to drill into nested data:
$ echo '{"response": {"data": {"name": "Joris"}}}' | yves --root response.data
{
"name": "Joris"
}Filter with --query
Query arrays using MongoDB-style expressions. Supports jsonic relaxed syntax — no braces or quotes needed:
# strict JSON
$ cat data.json | yves --query '{"status": "active"}'
# jsonic shorthand (equivalent)
$ cat data.json | yves --query status:active
# multiple conditions
$ cat data.json | yves --query 'status:active,role:admin'
# $in operator
$ cat data.json | yves --query 'id:{$in:[1,2,3]}'Pick fields with --fields
Select specific fields from array items:
$ cat data.json | yves --fields id,name,emailCombine options
$ cat response.json | yves --root results --query 'status:published' --fields id,title