sensu-cli 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjBmYzYyYmQ2MzI3Y2M1YmRjNjU4OWQ5NDg3NmE3Yzg0M2UyODE4ZA==
4
+ YTBkNzc4ZGU4NzM5YzE5ZmFlYjI1MDc4OWVjN2FlMGUxNmMzZjE5YQ==
5
5
  data.tar.gz: !binary |-
6
- YzhmYThlNmExMGM2NzlkMmMyYWZmZDY4YmY3MGY3NGVjMTExMjJjMw==
6
+ N2JlZGE0NmNiMjJiODFiOTUyNmQ3ZjI1NTVmZjI1NjE4NGRjMjVlNA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjkxYWI5MjRlOTY1NzY2NGUxZTNhN2JhNmViYzRlYTdmYjQ3MDYwZGZhOWRm
10
- NzNmZDlmMjFlY2QyMWM3ZTBkYjAzMDhhNTYxMjRkMmM4OWU0ZDBiODZkM2M2
11
- MzAxODU0ZGM1MDliMzI3MDQyOWRlYWJkYWI4ZDhhMzNkNDlkYTA=
9
+ NDI1NWRiMTk4MjRmZWQwZTJlN2YzNGVjYTFhOGVjNGZlMjY5YjAzMDA0ZGJj
10
+ NjhjOTEyMjlmOTZkMzY0MGY0YjE4YTAxOWJjM2NlODk5NWE0ZTIxZjkwY2Zh
11
+ NmI5YTVhNDU3NTFlZjMxNTVmZmQwNGNjNGE1OTcxNWNjNTcxZWQ=
12
12
  data.tar.gz: !binary |-
13
- ZDA1ZjIwYjFiYjYxOGE5YzAxNDQxNWQ3Y2M5NmFkNjk4OGM4YTVhMTAwMzg4
14
- NTlkODA5YzRhNzgxNTY0NjdiOTFkZmQyZGZhNGY2NmM1N2U0YjEyYjgwMjg0
15
- MDU5MWM5Y2Q2M2FmYThiOTQwZDIyOGM0ZmJiMjA2NzhhYmE0NTQ=
13
+ ZDQzZGM5NGVhNjhmNGRhNmEzNGJmN2IyYzQzZTk3N2E2YWE5ZmI5YzIyN2Qz
14
+ ZmY1MGQzZjk0MGE0MDNhMzQ1ZmVmMjJhNGVmNmZkZTI2MGI0MDg3M2FiZTRj
15
+ ZjY5NzVhZTI4OWQyZjBhOWNjYzJhZTg4NjdhNTZlZTVkYjJmOWQ=
@@ -47,15 +47,16 @@ module SensuCli
47
47
  exit
48
48
  elsif @cli[:fields][:format] == 'single'
49
49
  Pretty.single(msg)
50
- Pretty.count(msg)
51
50
  elsif @cli[:fields][:format] == 'table'
52
51
  endpoint = @api[:command]
53
52
  fields = nil || @cli[:fields][:fields]
54
53
  Pretty.table(msg, endpoint, fields)
54
+ elsif @cli[:fields][:format] == 'json'
55
+ Pretty.json(msg)
55
56
  else
56
57
  Pretty.print(msg)
57
- Pretty.count(msg)
58
58
  end
59
+ Pretty.count(msg) unless @cli[:fields][:format] == 'table'
59
60
  end
60
61
 
61
62
  end
@@ -38,7 +38,7 @@ module SensuCli
38
38
  EOS
39
39
  EVENT_BANNER = <<-EOS.gsub(/^ {10}/, '')
40
40
  ** Event Commands **
41
- sensu-cli event list
41
+ sensu-cli event list (OPTIONS)
42
42
  sensu-cli event show NODE (OPTIONS)
43
43
  sensu-cli event delete NODE CHECK\n\r
44
44
  EOS
@@ -139,7 +139,7 @@ module SensuCli
139
139
  opt :format, 'Available formats; single, table', :short => 'f', :type => :string
140
140
  opt :fields, 'Fields for table ouput: -F name,address,subscriptions', :short => 'F', :type => :string
141
141
  end
142
- Trollop::die :format, 'Available optional formats: single, table'.color(:red) if p[:format] != 'table' && p[:format] != 'single' && p[:format]
142
+ Trollop::die :format, 'Available optional formats: single, table'.color(:red) if p[:format] != 'table' && p[:format] != 'single' && p[:format] != 'json' && p[:format]
143
143
  Trollop::die :fields, 'Fields must be used in conjunction with --format table'.color(:red) if p[:format] != 'table' && p[:fields]
144
144
  Trollop::die :offset, 'Offset depends on the limit option --limit ( -l )'.color(:red) if p[:offset] && !p[:limit]
145
145
  { :command => 'clients', :method => 'Get', :fields => p }
@@ -203,7 +203,7 @@ module SensuCli
203
203
  p = Trollop::options do
204
204
  opt :format, 'Available formats; single, table', :short => 'f', :type => :string
205
205
  end
206
- Trollop::die :format, 'Available optional formats: single, table'.color(:red) if p[:format] != 'table' && p[:format] != 'single' && p[:format]
206
+ Trollop::die :format, 'Available optional formats: single, table'.color(:red) if p[:format] != 'table' && p[:format] != 'single' && p[:format] != 'json' && p[:format]
207
207
  { :command => 'events', :method => 'Get', :fields => p }
208
208
  when 'show'
209
209
  p = Trollop::options do
@@ -231,8 +231,10 @@ module SensuCli
231
231
  p = Trollop::options do
232
232
  opt :limit, 'The number of stashes to return', :short => 'l', :type => :string
233
233
  opt :offset, 'The number of stashes to offset before returning', :short => 'o', :type => :string
234
+ opt :format, 'Available formats; single, table', :short => 'f', :type => :string
234
235
  end
235
236
  Trollop::die :offset, 'Offset depends on the limit option --limit ( -l )'.color(:red) if p[:offset] && !p[:limit]
237
+ Trollop::die :format, 'Available optional formats: single, table'.color(:red) if p[:format] != 'table' && p[:format] != 'single' && p[:format] != 'json' && p[:format]
236
238
  { :command => 'stashes', :method => 'Get', :fields => p }
237
239
  when 'show'
238
240
  p = Trollop::options
@@ -1,6 +1,6 @@
1
1
  require 'rainbow'
2
2
  require 'hirb'
3
- require 'terminfo'
3
+ require 'json'
4
4
 
5
5
  module SensuCli
6
6
  class Pretty
@@ -29,6 +29,10 @@ module SensuCli
29
29
  end
30
30
  end
31
31
 
32
+ def json(res)
33
+ puts JSON.pretty_generate(res)
34
+ end
35
+
32
36
  def count(res)
33
37
  res.is_a?(Hash) ? count = res.length : count = res.count
34
38
  puts "#{count} total items".color(:yellow) if count
@@ -87,7 +91,7 @@ module SensuCli
87
91
  def table(res, endpoint, fields = nil)
88
92
  if !res.empty?
89
93
  if res.is_a?(Array)
90
- terminal_size = TermInfo.screen_size
94
+ terminal_size = Hirb::Util.detect_terminal_size
91
95
  if endpoint == 'events'
92
96
  keys = %w[check client status flapping occurrences handlers issued output]
93
97
  else
@@ -97,7 +101,7 @@ module SensuCli
97
101
  keys = res.map { |item| item.keys }.flatten.uniq
98
102
  end
99
103
  end
100
- puts Hirb::Helpers::AutoTable.render(res, { :max_width => terminal_size[1], :fields => keys })
104
+ puts Hirb::Helpers::AutoTable.render(res, { :max_width => terminal_size[0], :fields => keys })
101
105
  end
102
106
  else
103
107
  self.no_values
@@ -1,3 +1,3 @@
1
1
  module SensuCli
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
@@ -16,7 +16,6 @@ Gem::Specification.new do |s|
16
16
  s.add_dependency('trollop', '2.0')
17
17
  s.add_dependency('mixlib-config', '1.1.2')
18
18
  s.add_dependency('hirb', '0.7.1')
19
- s.add_dependency('ruby-terminfo', '0.1.1')
20
19
 
21
20
  s.add_development_dependency('rspec')
22
21
  s.add_development_dependency('rubocop')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Brandau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-05 00:00:00.000000000 Z
11
+ date: 2013-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.7.1
69
- - !ruby/object:Gem::Dependency
70
- name: ruby-terminfo
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '='
74
- - !ruby/object:Gem::Version
75
- version: 0.1.1
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '='
81
- - !ruby/object:Gem::Version
82
- version: 0.1.1
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rspec
85
71
  requirement: !ruby/object:Gem::Requirement