- Copy
prissyto~/bin(or elsewhere in your$PATH) chmod +x prissygem install awesome_print multi_json
$ some_command_that_outputs_json | prissy
| #!/usr/bin/env ruby | |
| begin | |
| require 'awesome_print' | |
| require 'multi_json' | |
| rescue LoadError | |
| warn "prissy needs the `awesome_print` and `multi_json` gems available to do its job" | |
| puts STDIN.read | |
| raise | |
| end | |
| opts = { | |
| :indent => 2, | |
| :index => false, | |
| :sort_keys => true | |
| } | |
| begin | |
| ap MultiJson.decode(STDIN), opts | |
| rescue | |
| warn "this doesn't look like JSON..." | |
| puts STDIN.read | |
| end |