jeep-cli v0.0.4
JEEP
JEEP is a small command line utility for processing JSON text.
It provides, filtering, sorting, plucking fields, etc. It was created to be
used when making API calls with curl that return JSON.
Quick examples:
Update: Pull requests default to Open by default so this example is not the best, but you ge the idea. I'll update this soon hopefully, maybe, probably not.
# Get all tag names for rails repository
curl https://api.github.com/repos/rails/rails/tags | jeep -p "name"
# Get count of tag names for rails repository
curl https://api.github.com/repos/rails/rails/tags | jeep -c
# Get all open pull requests
curl https://api.github.com/repos/rails/rails/pulls | jeep -w '{state: "Open"}'
# Get count of all open pull requests
curl https://api.github.com/repos/rails/rails/pulls | jeep -w '{state: "Open"}' -cInstallation
npm install -g jeep-cliDocumentation
Most arguments can be combined. For example you can filter, sort and return the first item remaining. Or filter the data and get the count of the remaining items.
Count items in array (-c or --count)
echo '["John","Steve"]' | jeep -c # returns 2Return first item in array (-f or --first)
echo '["John,"Steve"]' | jeep -f # returns "John"Returns keys for an object (k or --keys)
# Returns ["id","name","email"]
echo '{"id": 1, "name": "John", email: "john@email.com"}' | jeep -kReturn last item in array (-l or --last)
echo '["John,"Steve"]' | jeep -l # returns "Steve"Pluck property names from array (-p or --pluck)
Pluck can be be a single property or a comma separated list of properties
# returns ["john","steve"]
echo '[{"name":"john","id":1},{"name":"steve","id":2}]' | jeep -p "name"
# returns title and status of all pull requests
curl https://api.github.com/repos/rails/rails/pulls | jeep -p "title,status"Sort by property name (-s --sortBy)
# Returns array sorted by id in ascending order
echo '[{id:5},{id:7},{id:3}]' | jeep -s "id"Sort by property name descending (-S --sortByDesc)
# Returns array sorted by id in descending order
echo '[{id:5},{id:7},{id:3}]' | jeep -S "id"Simple filter by property values (-w --where)
# Filters records by 'Open' state
curl https://api.github.com/repos/rails/rails/pulls | jeep -w '{state:"Open"}'Other
jeep -h # View help (-h or --help)
jeep -v # View version (-V or --version)Formatted and colourful JSON output
Right now I just use the awesome pjson tool for this.
curl https://api.github.com/repos/rails/rails/pulls | jeep -s "title" | pjsonThe name JEEP?
Json Eliminater, Editor and Processor...ok that's not really true. I just wanted a three or four letter name that started with J. And all the good ones are taken of course...
License
Copyright (c) Craig MacGregor 2015 under MIT LICENSE