cmd2json 0.1.0 → 0.1.1
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/bin/cmd2json +2 -0
- data/lib/cmd2json.rb +4 -1
- data/lib/cmd2json/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: 1776ecf5855f37c7cd810f89ec568635c5a887c3
|
4
|
+
data.tar.gz: 81f34b3d6f9a6f0b9c683c0b0956fcea7cb1277f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9b018a57cef46bf5579d2c8efb6e2d53a304424a0ec215505a8e25a1cfeaf196b7020f2cfc68846f9cf2f7739c7b05f952f7f7905bcb384e27818830895df6e
|
7
|
+
data.tar.gz: 11a9fe137ca199a04f7220704ebb383fec45fd8118c803847e367267c96edffc5406dbff0da3dc7d7c0a0f22fcf724bfcf5b5f6cd5ac229d41235ed4232ff10e
|
data/bin/cmd2json
CHANGED
@@ -15,6 +15,8 @@ Usage:
|
|
15
15
|
Options:
|
16
16
|
BANNER
|
17
17
|
opts.on("-a", "--add KEY=VALUE", "add a key value pair") { |v| options[:add].send(:[]=, *v.split('=', 2)) }
|
18
|
+
opts.on("-t", "--timestamp", "add @timestamp") { options[:timestamp] = true }
|
19
|
+
opts.on("--host", "add host") { options[:host] = true }
|
18
20
|
opts.on("-h", "--help", "Show this.") { puts opts; exit }
|
19
21
|
opts.on('-v', '--version', 'Show Version'){ puts Cmd2Json::VERSION; exit 0 }
|
20
22
|
end
|
data/lib/cmd2json.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'socket'
|
2
3
|
|
3
4
|
module Cmd2Json
|
4
5
|
def self.run(argv, options={})
|
@@ -10,7 +11,9 @@ module Cmd2Json
|
|
10
11
|
out = $!.message
|
11
12
|
status = 1
|
12
13
|
end
|
13
|
-
result = {message: out, exit: status
|
14
|
+
result = {message: out, exit: status}
|
15
|
+
result['@timestamp'] = Time.now if options[:timestamp]
|
16
|
+
result[:host] = Socket.gethostname if options[:host]
|
14
17
|
[status, result.merge(options[:add] || {}).to_json]
|
15
18
|
end
|
16
19
|
|
data/lib/cmd2json/version.rb
CHANGED