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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30c35dc495f05fb90247a531378b7308712fa1f0
4
- data.tar.gz: f8e44d965233d477f9eed080d494a4543363c77a
3
+ metadata.gz: 1776ecf5855f37c7cd810f89ec568635c5a887c3
4
+ data.tar.gz: 81f34b3d6f9a6f0b9c683c0b0956fcea7cb1277f
5
5
  SHA512:
6
- metadata.gz: c3bb7496d632dcf0bbc1651218cabc2224618bb6e52cdfbfb976db2f592542524102895ef40e5f9f769db89a572c2f2b3600a217dd85abd37c391a79d6b444e9
7
- data.tar.gz: 38b407c7805f77ee108c51f82431adb23aca673a49010c347ebb41220e0b44b5789ef5df0feb88d53289459493937ce82d123cd5aa8ec7aa1cb2b81ddefdf74a
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, timestamp: Time.now.to_s}
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
 
@@ -1,3 +1,3 @@
1
1
  module Cmd2Json
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmd2json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser