cli-format 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +8 -0
- data/lib/cli_format/presenter/json.rb +7 -4
- data/lib/cli_format/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7787622c725718db9f2da155ca771914a479461de6c951a8bc98472e11f87720
|
4
|
+
data.tar.gz: fe8d99d2638510e4f86e0203c38aa641f5793aecfbb40c6a46fe41ff9ed95ba9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5de20b08ef2460450a2fa788d0b1c4610b414224b09e9554a252f48feea03f4fa1ca6969c688c5543c11672c14e82c44e4e84842e14be21624205f001962d2de
|
7
|
+
data.tar.gz: 91fdca86887bf627851cb6a5bf42ed6adbf615885a5f32713203a458d51c1bb4a0983a7a2deb79b1a4c1f4344ce84e9ce82460c95810d4d07d2906be0dee23e0
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
This project *loosely* adheres to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
|
+
|
6
|
+
## [0.2.0]
|
7
|
+
- #1 improve json format output - better usage with jq
|
8
|
+
|
9
|
+
## [0.1.0]
|
10
|
+
- Initial release.
|
data/README.md
CHANGED
@@ -71,6 +71,14 @@ Format json shows:
|
|
71
71
|
}
|
72
72
|
```
|
73
73
|
|
74
|
+
## Thor CLI Options
|
75
|
+
|
76
|
+
To expose the format in Thor CLI options, you can use `CliFormat.formats`. Example:
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
option :format, desc: "Output formats: #{CliFormat.formats.join(', ')}"
|
80
|
+
```
|
81
|
+
|
74
82
|
## Text
|
75
83
|
|
76
84
|
If you would like to grab just the text and not it shown, use the `text` method.
|
@@ -3,10 +3,13 @@ require "json"
|
|
3
3
|
class CliFormat::Presenter
|
4
4
|
class Json < Base
|
5
5
|
def text
|
6
|
-
json_data =
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
json_data = @rows.map do |row|
|
7
|
+
item = {}
|
8
|
+
@header.each_with_index do |header, i|
|
9
|
+
item[header] = row[i]
|
10
|
+
end
|
11
|
+
item
|
12
|
+
end
|
10
13
|
JSON.pretty_generate(json_data)
|
11
14
|
end
|
12
15
|
end
|
data/lib/cli_format/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cli-format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- ".gitignore"
|
105
105
|
- ".rspec"
|
106
106
|
- ".travis.yml"
|
107
|
+
- CHANGELOG.md
|
107
108
|
- Gemfile
|
108
109
|
- Gemfile.lock
|
109
110
|
- LICENSE.txt
|