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 +8 -8
- data/lib/sensu-cli/base.rb +3 -2
- data/lib/sensu-cli/cli.rb +5 -3
- data/lib/sensu-cli/pretty.rb +7 -3
- data/lib/sensu-cli/version.rb +1 -1
- data/sensu-cli.gemspec +0 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTBkNzc4ZGU4NzM5YzE5ZmFlYjI1MDc4OWVjN2FlMGUxNmMzZjE5YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2JlZGE0NmNiMjJiODFiOTUyNmQ3ZjI1NTVmZjI1NjE4NGRjMjVlNA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDI1NWRiMTk4MjRmZWQwZTJlN2YzNGVjYTFhOGVjNGZlMjY5YjAzMDA0ZGJj
|
10
|
+
NjhjOTEyMjlmOTZkMzY0MGY0YjE4YTAxOWJjM2NlODk5NWE0ZTIxZjkwY2Zh
|
11
|
+
NmI5YTVhNDU3NTFlZjMxNTVmZmQwNGNjNGE1OTcxNWNjNTcxZWQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDQzZGM5NGVhNjhmNGRhNmEzNGJmN2IyYzQzZTk3N2E2YWE5ZmI5YzIyN2Qz
|
14
|
+
ZmY1MGQzZjk0MGE0MDNhMzQ1ZmVmMjJhNGVmNmZkZTI2MGI0MDg3M2FiZTRj
|
15
|
+
ZjY5NzVhZTI4OWQyZjBhOWNjYzJhZTg4NjdhNTZlZTVkYjJmOWQ=
|
data/lib/sensu-cli/base.rb
CHANGED
@@ -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
|
data/lib/sensu-cli/cli.rb
CHANGED
@@ -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
|
data/lib/sensu-cli/pretty.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rainbow'
|
2
2
|
require 'hirb'
|
3
|
-
require '
|
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 =
|
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[
|
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
|
data/lib/sensu-cli/version.rb
CHANGED
data/sensu-cli.gemspec
CHANGED
@@ -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.
|
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-
|
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
|