so-pretty 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -0
- data/lib/so-pretty.rb +33 -2
- data/lib/so-pretty/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 100ba0b3c6d2d72a42f55e3d7aa5e06b6f61dce9
|
4
|
+
data.tar.gz: 6ad553a0192ab14995e306cff44a9ce7bf80be58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4883640bcf017232553c3036dc0645dc254329fffd4a464b790bc25a5140128e2f06345c0e5feb7c4211a74a6ae76e4106f4a0d515637d7683968e24fb86912e
|
7
|
+
data.tar.gz: 679699610a7bf11bdf3854758afb52cfece142ddf1176f709c1dc22c4fb26e77cd630d23a13ef14fbc46a0a551aa5560d8767989e09c861f8856e26792c9a9ed
|
data/README.md
CHANGED
@@ -13,3 +13,22 @@ Usage: sp [options]
|
|
13
13
|
* csv
|
14
14
|
* toml
|
15
15
|
* some specs would be nice
|
16
|
+
|
17
|
+
## Examples
|
18
|
+
|
19
|
+
$ echo '{"foo":"bar"}' | sp -f ruby
|
20
|
+
> {
|
21
|
+
> "foo" => "bar"
|
22
|
+
> }
|
23
|
+
|
24
|
+
$ echo '{"foo":"bar"}' | sp -f json
|
25
|
+
> {
|
26
|
+
> "foo": "bar"
|
27
|
+
> }
|
28
|
+
|
29
|
+
$ echo '{"foo":"bar"}' | sp -f yaml
|
30
|
+
> ---
|
31
|
+
> foo: bar
|
32
|
+
|
33
|
+
$ echo '{"foo":"bar"}' | sp -f minjson
|
34
|
+
> {"foo":"bar"}
|
data/lib/so-pretty.rb
CHANGED
@@ -5,6 +5,7 @@ require 'json'
|
|
5
5
|
require 'zlib'
|
6
6
|
require 'yaml'
|
7
7
|
require 'optparse'
|
8
|
+
require 'so-pretty/version'
|
8
9
|
|
9
10
|
begin
|
10
11
|
require 'awesome_print'
|
@@ -105,18 +106,29 @@ module SoPretty
|
|
105
106
|
|
106
107
|
parser = OptionParser.new do |opts|
|
107
108
|
opts.banner = "Usage: sp [options]"
|
109
|
+
opts.separator ""
|
110
|
+
opts.separator "Options:"
|
108
111
|
|
109
|
-
opts.on( "-i", "--input [instream]", "Input stream, one of: '-', 'STDIN', or a file name" ) do |instream|
|
112
|
+
opts.on( "-i", "--input [instream]", "Input stream, one of: '-', 'STDIN', or a file name. default: '-'" ) do |instream|
|
110
113
|
options[:instream] = instream
|
111
114
|
end
|
112
115
|
|
113
|
-
opts.on( "-o", "--output [outstream]", "Output stream, one of: '-', 'STDOUT', 'STDERR' or a file name" ) do |outstream|
|
116
|
+
opts.on( "-o", "--output [outstream]", "Output stream, one of: '-', 'STDOUT', 'STDERR' or a file name. default: '-'" ) do |outstream|
|
114
117
|
options[:outstream] = outstream
|
115
118
|
end
|
116
119
|
|
117
120
|
opts.on( "-f", "--format [format]", "Output format, one of: 'yaml', 'json', 'ruby', 'minjson'") do |format|
|
118
121
|
options[:format] = format.to_sym
|
119
122
|
end
|
123
|
+
|
124
|
+
opts.on("-V", "--version", "Show version") do
|
125
|
+
puts VERSION
|
126
|
+
exit
|
127
|
+
end
|
128
|
+
|
129
|
+
opts.separator ""
|
130
|
+
opts.separator "Examples:"
|
131
|
+
opts.separator EXAMPLES
|
120
132
|
end
|
121
133
|
|
122
134
|
parser.parse( argv )
|
@@ -150,4 +162,23 @@ module SoPretty
|
|
150
162
|
return File.open( maybe_stream, mode )
|
151
163
|
end
|
152
164
|
end
|
165
|
+
|
166
|
+
EXAMPLES=<<EOD
|
167
|
+
$ echo '{"foo":"bar"}' | sp -f ruby
|
168
|
+
> {
|
169
|
+
> "foo" => "bar"
|
170
|
+
> }
|
171
|
+
|
172
|
+
$ echo '{"foo":"bar"}' | sp -f json
|
173
|
+
> {
|
174
|
+
> "foo": "bar"
|
175
|
+
> }
|
176
|
+
|
177
|
+
$ echo '{"foo":"bar"}' | sp -f yaml
|
178
|
+
> ---
|
179
|
+
> foo: bar
|
180
|
+
|
181
|
+
$ echo '{"foo":"bar"}' | sp -f minjson
|
182
|
+
> {"foo":"bar"}
|
183
|
+
EOD
|
153
184
|
end
|
data/lib/so-pretty/version.rb
CHANGED