Created
December 19, 2013 08:35
-
-
Save mkdynamic/8036196 to your computer and use it in GitHub Desktop.
Pretty print JSON command.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'optparse' | |
require 'json' | |
options = {} | |
OptionParser.new do |opts| | |
opts.banner = "Usage: example.rb [options]" | |
opts.on("-x", "--extended", "Use awesome print") do |*| | |
options[:extended] = true | |
end | |
end.parse! | |
json = JSON.parse($stdin.read) | |
unless options[:extended] | |
jj json | |
else | |
require 'awesome_print' | |
ap json | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment