sensu-cli 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8871178111404ee69ec2bc65656b2ed2291f805ab8358bec3793f22422167903
4
- data.tar.gz: 68fb00fb7dcefd836a42a7acd089bf7bfcc3ffa8d0c8419644c1d8b0059c0ce1
3
+ metadata.gz: 96faf8014147d26794fbac8ba9f9552096305d372c04aa63e1c16c714d75624e
4
+ data.tar.gz: ef07d7f98178be6c29c418e803f8774822768cbcd56245d0c8d3546c21eca77f
5
5
  SHA512:
6
- metadata.gz: 12d137688641d447098f937d67c014eeb5fe0f9a98fd0ea65273666d6c35ae95070cda90366542167418aabc5b4e29594175a89e3c016f1928d9155b267c0f1e
7
- data.tar.gz: d07ade1488734b94707d50ffbe37cc37cebfa942d3a64c6c8a60e56704559d2de2e3de4485b52be5706310b4534e5e7fc44f486b1f4c442f71cac58adb40053a
6
+ metadata.gz: d7467480b2b1ab841df0a9fe23f5e1c6bb9dfef7ff9136780a6fbfaf387f3ecfcb02c29c025ce50a72d72e00a7bfc4dbdc517143505c1d30921fee838287fb35
7
+ data.tar.gz: fb59a9e7e6bfc44c5088c64d959ec2c22c5c85208c3a819b23f06d43ac89dd8a798510f07cce2a1a2d2e2bd82bec0f9bfc9d2093be8df49376f3e2e277b8433e
@@ -1,4 +1,4 @@
1
- require 'trollop'
1
+ require 'optimist'
2
2
  require 'sensu-cli/version'
3
3
  require 'rainbow/ext/string'
4
4
 
@@ -79,7 +79,7 @@ module SensuCli
79
79
  sensu-cli socket raw INPUT\n\r
80
80
  EOS
81
81
  def global
82
- global_opts = Trollop::Parser.new do
82
+ global_opts = Optimist::Parser.new do
83
83
  version "sensu-cli version: #{SensuCli::VERSION}"
84
84
  banner <<-'EOS'.gsub(/^ {10}/, '')
85
85
  #
@@ -108,17 +108,17 @@ module SensuCli
108
108
  banner SOCKET_BANNER
109
109
  stop_on SUB_COMMANDS
110
110
  end
111
- Trollop::with_standard_exception_handling global_opts do
111
+ Optimist::with_standard_exception_handling global_opts do
112
112
  global_opts.parse ARGV
113
- raise Trollop::HelpNeeded if ARGV.empty? # show help screen
113
+ raise Optimist::HelpNeeded if ARGV.empty? # show help screen
114
114
  end
115
115
  cmd = next_argv
116
116
  self.respond_to?(cmd) ? send(cmd) : explode(global_opts)
117
117
  end
118
118
 
119
119
  def explode(opts)
120
- Trollop::with_standard_exception_handling opts do
121
- raise Trollop::HelpNeeded # show help screen
120
+ Optimist::with_standard_exception_handling opts do
121
+ raise Optimist::HelpNeeded # show help screen
122
122
  end
123
123
  end
124
124
 
@@ -127,7 +127,7 @@ module SensuCli
127
127
  end
128
128
 
129
129
  def parser(cli)
130
- Trollop::Parser.new do
130
+ Optimist::Parser.new do
131
131
  banner Cli.const_get("#{cli}_BANNER")
132
132
  stop_on Cli.const_get("#{cli}_COMMANDS")
133
133
  end
@@ -147,27 +147,27 @@ module SensuCli
147
147
  explode_if_empty(opts, command)
148
148
  case command
149
149
  when 'list'
150
- p = Trollop::options do
150
+ p = Optimist::options do
151
151
  opt :limit, 'The number if clients to return', :short => 'l', :type => :string
152
152
  opt :offset, 'The number of clients to offset before returning', :short => 'o', :type => :string
153
153
  opt :format, 'Available formats; single, table, json', :short => 'f', :type => :string
154
154
  opt :fields, 'Fields for table ouput: -F name,address,subscriptions', :short => 'F', :type => :string
155
155
  opt :filter, 'Field and value to filter on: name,graphite', :type => :string
156
156
  end
157
- Trollop::die :format, 'Available optional formats: single, table, json'.color(:red) if p[:format] != 'table' && p[:format] != 'single' && p[:format] != 'json' && p[:format]
158
- Trollop::die :fields, 'Fields must be used in conjunction with --format table'.color(:red) if p[:format] != 'table' && p[:fields]
159
- Trollop::die :offset, 'Offset depends on the limit option --limit ( -l )'.color(:red) if p[:offset] && !p[:limit]
157
+ Optimist::die :format, 'Available optional formats: single, table, json'.color(:red) if p[:format] != 'table' && p[:format] != 'single' && p[:format] != 'json' && p[:format]
158
+ Optimist::die :fields, 'Fields must be used in conjunction with --format table'.color(:red) if p[:format] != 'table' && p[:fields]
159
+ Optimist::die :offset, 'Offset depends on the limit option --limit ( -l )'.color(:red) if p[:offset] && !p[:limit]
160
160
  { :command => 'clients', :method => 'Get', :fields => p }
161
161
  when 'delete'
162
- p = Trollop::options
163
- item = next_argv # the ARGV.shift needs to happen after Trollop::options to catch --help
162
+ p = Optimist::options
163
+ item = next_argv # the ARGV.shift needs to happen after Optimist::options to catch --help
164
164
  deep_merge({ :command => 'clients', :method => 'Delete', :fields => { :name => item } }, { :fields => p })
165
165
  when 'show'
166
- p = Trollop::options
166
+ p = Optimist::options
167
167
  item = next_argv
168
168
  deep_merge({ :command => 'clients', :method => 'Get', :fields => { :name => item } }, { :fields => p })
169
169
  when 'history'
170
- p = Trollop::options
170
+ p = Optimist::options
171
171
  item = next_argv
172
172
  deep_merge({ :command => 'clients', :method => 'Get', :fields => { :name => item, :history => true } }, { :fields => p })
173
173
  else
@@ -177,13 +177,13 @@ module SensuCli
177
177
 
178
178
  def info
179
179
  parser('INFO')
180
- p = Trollop::options
180
+ p = Optimist::options
181
181
  { :command => 'info', :method => 'Get', :fields => p }
182
182
  end
183
183
 
184
184
  def health
185
185
  parser('HEALTH')
186
- p = Trollop::options do
186
+ p = Optimist::options do
187
187
  opt :consumers, 'The minimum number of consumers', :short => 'c', :type => :string, :required => true
188
188
  opt :messages, 'The maximum number of messages', :short => 'm', :type => :string, :required => true
189
189
  end
@@ -197,15 +197,15 @@ module SensuCli
197
197
  item = next_argv
198
198
  case command
199
199
  when 'list'
200
- p = Trollop::options do
200
+ p = Optimist::options do
201
201
  opt :filter, 'Field and value to filter on: command,procs', :type => :string
202
202
  end
203
203
  { :command => 'checks', :method => 'Get', :fields => p }
204
204
  when 'show'
205
- p = Trollop::options
205
+ p = Optimist::options
206
206
  deep_merge({ :command => 'checks', :method => 'Get', :fields => { :name => item } }, { :fields => p })
207
207
  when 'request'
208
- p = Trollop::options
208
+ p = Optimist::options
209
209
  ARGV.empty? ? explode(opts) : subscribers = next_argv.split(',')
210
210
  deep_merge({ :command => 'checks', :method => 'Post', :fields => { :check => item, :subscribers => subscribers } }, { :fields => p })
211
211
  else
@@ -219,20 +219,20 @@ module SensuCli
219
219
  explode_if_empty(opts, command)
220
220
  case command
221
221
  when 'list'
222
- p = Trollop::options do
222
+ p = Optimist::options do
223
223
  opt :filter, 'Field and value to filter on: client,graphite (use "name" as field for client or event name)', :type => :string
224
224
  opt :format, 'Available formats; single, table, json', :short => 'f', :type => :string
225
225
  end
226
- Trollop::die :format, 'Available optional formats: single, table, json'.color(:red) if p[:format] != 'table' && p[:format] != 'single' && p[:format] != 'json' && p[:format]
226
+ Optimist::die :format, 'Available optional formats: single, table, json'.color(:red) if p[:format] != 'table' && p[:format] != 'single' && p[:format] != 'json' && p[:format]
227
227
  { :command => 'events', :method => 'Get', :fields => p }
228
228
  when 'show'
229
- p = Trollop::options do
229
+ p = Optimist::options do
230
230
  opt :check, 'Returns the check associated with the client', :short => 'k', :type => :string
231
231
  end
232
232
  item = next_argv
233
233
  deep_merge({ :command => 'events', :method => 'Get', :fields => { :client => item } }, { :fields => p })
234
234
  when 'delete'
235
- p = Trollop::options
235
+ p = Optimist::options
236
236
  item = next_argv
237
237
  check = next_argv
238
238
  explode(opts) if check.nil?
@@ -248,25 +248,25 @@ module SensuCli
248
248
  explode_if_empty(opts, command)
249
249
  case command
250
250
  when 'list'
251
- p = Trollop::options do
251
+ p = Optimist::options do
252
252
  opt :limit, 'The number of stashes to return', :short => 'l', :type => :string
253
253
  opt :offset, 'The number of stashes to offset before returning', :short => 'o', :type => :string
254
254
  opt :format, 'Available formats; single, table, json', :short => 'f', :type => :string
255
255
  opt :filter, 'Field and value to filter on: path,graphite', :type => :string
256
256
  end
257
- Trollop::die :offset, 'Offset depends on the limit option --limit ( -l )'.color(:red) if p[:offset] && !p[:limit]
258
- Trollop::die :format, 'Available optional formats: single, table, json'.color(:red) if p[:format] != 'table' && p[:format] != 'single' && p[:format] != 'json' && p[:format]
257
+ Optimist::die :offset, 'Offset depends on the limit option --limit ( -l )'.color(:red) if p[:offset] && !p[:limit]
258
+ Optimist::die :format, 'Available optional formats: single, table, json'.color(:red) if p[:format] != 'table' && p[:format] != 'single' && p[:format] != 'json' && p[:format]
259
259
  { :command => 'stashes', :method => 'Get', :fields => p }
260
260
  when 'show'
261
- p = Trollop::options
261
+ p = Optimist::options
262
262
  item = next_argv
263
263
  deep_merge({ :command => 'stashes', :method => 'Get', :fields => { :path => item } }, { :fields => p })
264
264
  when 'delete'
265
- p = Trollop::options
265
+ p = Optimist::options
266
266
  item = next_argv
267
267
  deep_merge({ :command => 'stashes', :method => 'Delete', :fields => { :path => item } }, { :fields => p })
268
268
  when 'create'
269
- p = Trollop::options
269
+ p = Optimist::options
270
270
  item = next_argv
271
271
  deep_merge({ :command => 'stashes', :method => 'Post', :fields => { :create => true, :create_path => item } }, { :fields => p })
272
272
  else
@@ -280,22 +280,22 @@ module SensuCli
280
280
  explode_if_empty(opts, command)
281
281
  case command
282
282
  when 'list'
283
- p = Trollop::options do
283
+ p = Optimist::options do
284
284
  opt :filter, 'Field and value to filter on: issued,1399505890', :type => :string
285
285
  end
286
286
  { :command => 'aggregates', :method => 'Get', :fields => p }
287
287
  when 'show'
288
- p = Trollop::options do
288
+ p = Optimist::options do
289
289
  opt :id, 'The id of the check issued.', :short => 'i', :type => :integer
290
290
  opt :limit, 'The number of aggregates to return', :short => 'l', :type => :string
291
291
  opt :offset, 'The number of aggregates to offset before returning', :short => 'o', :type => :string
292
292
  # opt :results, 'Include the check results', :short => 'r', :type => :boolean
293
293
  end
294
- Trollop::die :offset, 'Offset depends on the limit option --limit ( -l )'.color(:red) if p[:offset] && !p[:limit]
294
+ Optimist::die :offset, 'Offset depends on the limit option --limit ( -l )'.color(:red) if p[:offset] && !p[:limit]
295
295
  item = next_argv
296
296
  deep_merge({ :command => 'aggregates', :method => 'Get', :fields => { :check => item } }, { :fields => p })
297
297
  when 'delete'
298
- p = Trollop::options
298
+ p = Optimist::options
299
299
  item = next_argv
300
300
  deep_merge({ :command => 'aggregates', :method => 'Delete', :fields => { :check => item } }, { :fields => p })
301
301
  else
@@ -305,7 +305,7 @@ module SensuCli
305
305
 
306
306
  def silence
307
307
  opts = parser('SIL')
308
- p = Trollop::options do
308
+ p = Optimist::options do
309
309
  opt :check, 'The check to silence', :short => 'k', :type => :string
310
310
  opt :owner, 'The owner of the stash', :short => 'o', :type => :string
311
311
  opt :reason, 'The reason this check/node is being silenced', :short => 'r', :type => :string
@@ -323,16 +323,16 @@ module SensuCli
323
323
  explode_if_empty(opts, command)
324
324
  case command
325
325
  when 'list'
326
- p = Trollop::options do
326
+ p = Optimist::options do
327
327
  opt :check, 'The check entries to return', :short => 'c', :type => :string
328
328
  opt :subscription, 'The subscription entries to return', :short => 's', :type => :string
329
329
  opt :limit, 'The number of aggregates to return', :short => 'l', :type => :string
330
330
  opt :offset, 'The number of aggregates to offset before returning', :short => 'o', :type => :string
331
331
  end
332
- Trollop::die :offset, 'Offset depends on the limit option --limit ( -l )'.color(:red) if p[:offset] && !p[:limit]
332
+ Optimist::die :offset, 'Offset depends on the limit option --limit ( -l )'.color(:red) if p[:offset] && !p[:limit]
333
333
  { :command => 'silenced', :method => 'Get', :fields => p }
334
334
  when 'create'
335
- p = Trollop::options do
335
+ p = Optimist::options do
336
336
  opt :check, 'The check to silence', :short => 'c', :type => :string
337
337
  opt :creator, 'The owner of the stash', :short => 'o', :type => :string
338
338
  opt :reason, 'The reason this check/node is being silenced', :short => 'r', :type => :string, :default => 'Silenced via API - no reason given'
@@ -341,15 +341,15 @@ module SensuCli
341
341
  opt :source, 'The name of the source of the silence', :short => 's', :type => :string, :default => 'sensu-cli'
342
342
  opt :subscription, 'The name of the subscription to silence', :short => 'n', :type => :string
343
343
  end
344
- Trollop::die :check, 'Check or Subscription is required'.color(:red) if !p[:check] && !p[:subscription]
344
+ Optimist::die :check, 'Check or Subscription is required'.color(:red) if !p[:check] && !p[:subscription]
345
345
  deep_merge({ :command => 'silenced', :method => 'Post', :fields => { :create => true } }, { :fields => p })
346
346
  when 'clear'
347
- p = Trollop::options do
347
+ p = Optimist::options do
348
348
  opt :id, 'The id of the silenced item', :short => 'i', :type => :string
349
349
  opt :check, 'The check of the silenced item', :short => 'c', :type => :string
350
350
  opt :subscription, 'The subscription of the silenced item', :short => 's', :type => :string
351
351
  end
352
- Trollop::die :id, 'ID, Check or Subscription is required'.color(:red) if !p[:check] && !p[:subscription] && !p[:id]
352
+ Optimist::die :id, 'ID, Check or Subscription is required'.color(:red) if !p[:check] && !p[:subscription] && !p[:id]
353
353
  { :command => 'silenced', :method => 'Post', :clear => true, :fields => p }
354
354
  else
355
355
  explode(opts)
@@ -359,7 +359,7 @@ module SensuCli
359
359
  def resolve
360
360
  opts = parser('RES')
361
361
  command = next_argv
362
- p = Trollop::options
362
+ p = Optimist::options
363
363
  ARGV.empty? ? explode(opts) : check = next_argv
364
364
  deep_merge({ :command => 'resolve', :method => 'Post', :fields => { :client => command, :check => check } }, { :fields => p })
365
365
  end
@@ -370,7 +370,7 @@ module SensuCli
370
370
  explode_if_empty(opts, command)
371
371
  case command
372
372
  when 'create'
373
- p = Trollop::options do
373
+ p = Optimist::options do
374
374
  opt :name, 'The check name to report as', :short => 'n', :type => :string, :required => true
375
375
  opt :output, 'The check result output', :short => 'o', :type => :string, :required => true
376
376
  opt :status, 'The check result exit status to indicate severity.', :short => 's', :type => :integer
@@ -378,7 +378,7 @@ module SensuCli
378
378
  end
379
379
  { :command => 'socket', :method => 'create', :fields => p }
380
380
  when 'raw'
381
- Trollop::options
381
+ Optimist::options
382
382
  { :command => 'socket', :method => 'raw', :raw => next_argv }
383
383
  else
384
384
  explode(opts)
@@ -1,3 +1,3 @@
1
1
  module SensuCli
2
- VERSION = '0.10.0'
2
+ VERSION = '0.11.0'
3
3
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  else
18
18
  s.add_dependency('rainbow', '~> 2.0')
19
19
  end
20
- s.add_dependency('trollop', '~> 2.0')
20
+ s.add_dependency('optimist', '~> 3.0')
21
21
  s.add_dependency('mixlib-config', '~> 2.1')
22
22
  s.add_dependency('hirb', '~> 0.7')
23
23
  s.add_dependency('erubis', '~> 2.7')
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.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Brandau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-06 00:00:00.000000000 Z
11
+ date: 2019-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: trollop
28
+ name: optimist
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
33
+ version: '3.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.0'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mixlib-config
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -111,8 +111,8 @@ dependencies:
111
111
  description: A command line utility for interacting with the Sensu api.
112
112
  email: agent462@gmail.com
113
113
  executables:
114
- - sensu
115
114
  - sensu-cli
115
+ - sensu
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files: