wavefront-cli 2.16.2 → 2.17.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: 9a9ffb71cf822c08333a7064a3735eb3fb4d2e3ce890c0d2235b8c9c0aade72a
4
- data.tar.gz: 2246240b345f0c9ba242a78e8b2c771461cbe0e28570540ea02ae19a303e0643
3
+ metadata.gz: 409c2cb417bfe4b580a2d140a4088c030ddeaa676c7467372df205b3e9082ba5
4
+ data.tar.gz: 74392fb743bfdd8673eeaecf46f2997be75fa4296d7ad4625e7014e312654f2b
5
5
  SHA512:
6
- metadata.gz: 13daf5449067e63010d236b2366049365938e45485242e307fdf0d4341aaa105936134df033fc7c597e2d5af9494f457dac86db549e8aebadc1ceffbbd205c8c
7
- data.tar.gz: 292227d6380d59ff4b55ea527223803d9853e74edd66f3c308d2d976e39ffbb39df9a568d054bc3f47b349fbff695c6018dee82869dc653669beec7f78180563
6
+ metadata.gz: 555129158af2721bf4ebda76ebf3254e3aa1c1b6a2785c3a5e558a1a183bc36fa6591bd14447fa008d4f9a3b66e3ab5db9b6b0ad4388dd43a46c03a4bfb3ffc0
7
+ data.tar.gz: 16df485a8d0706ec14bf2be94c94ab898e5c69bfa36ad950fefb6fac9134cfc6fe10343c15be1e88ac4431a52fd968c6a19d3ae71f3ee99585658d2359621595
data/.travis.yml CHANGED
@@ -6,7 +6,7 @@ rvm:
6
6
  - 2.4.5
7
7
  - 2.5.3
8
8
  - 2.6.0
9
- before_install: gem install bundler --no-document
9
+ before_install: gem install bundler -v 1.17.3 --no-document
10
10
  deploy:
11
11
  provider: rubygems
12
12
  api_key:
data/HISTORY.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.17.0 (19/02/2019)
4
+ * Add `-O field,field` to all `list` commands. This lets you select
5
+ the fields displayed in the output.
6
+
3
7
  ## 2.16.2 (29/12/2018)
4
8
  * Fix typo in `query` help. CSV headers are produced with `-F
5
9
  headers`, not `-F header`.
@@ -8,7 +8,7 @@ class WavefrontCommandAlert < WavefrontCommandBase
8
8
  end
9
9
 
10
10
  def _commands
11
- ["list #{CMN} [-al] [-f format] [-o offset] [-L limit]",
11
+ ["list #{CMN} [-al] [-O fields] [-f format] [-o offset] [-L limit]",
12
12
  "firing #{CMN} [-f format] [-o offset] [-L limit]",
13
13
  "snoozed #{CMN} [-f format] [-o offset] [-L limit]",
14
14
  "describe #{CMN} [-f format] [-v version] <id>",
@@ -38,6 +38,7 @@ class WavefrontCommandAlert < WavefrontCommandBase
38
38
  '-a, --all list all alerts',
39
39
  '-v, --version=INTEGER describe only this version of alert',
40
40
  '-o, --offset=n start from nth alert',
41
+ '-O, --fields=F1,F2,... only show given fields',
41
42
  '-L, --limit=COUNT number of alerts to list',
42
43
  '-T, --time=SECONDS how long to snooze (default 3600)',
43
44
  '-b, --brief do not show alert names',
@@ -16,7 +16,7 @@ class WavefrontCommandCloudintegration < WavefrontCommandBase
16
16
  end
17
17
 
18
18
  def _commands
19
- ["list #{CMN} [-al] [-f format] [-o offset] [-L limit]",
19
+ ["list #{CMN} [-al] [-O fields] [-f format] [-o offset] [-L limit]",
20
20
  "describe #{CMN} [-f format] <id>",
21
21
  "delete #{CMN} <id>",
22
22
  "undelete #{CMN} <id>",
@@ -28,10 +28,11 @@ class WavefrontCommandCloudintegration < WavefrontCommandBase
28
28
 
29
29
  def _options
30
30
  [common_options,
31
- '-l, --long list cloud integrations in detail',
32
- '-a, --all list all cloud integrations',
33
- '-o, --offset=n start from nth cloud integration',
34
- '-L, --limit=COUNT number of cloud integrations to list',
35
- '-f, --format=STRING output format']
31
+ '-l, --long list cloud integrations in detail',
32
+ '-a, --all list all cloud integrations',
33
+ '-o, --offset=n start from nth cloud integration',
34
+ '-O, --fields=F1,F2,... only show given fields',
35
+ '-L, --limit=COUNT number of cloud integrations to list',
36
+ '-f, --format=STRING output format']
36
37
  end
37
38
  end
@@ -8,7 +8,7 @@ class WavefrontCommandDashboard < WavefrontCommandBase
8
8
  end
9
9
 
10
10
  def _commands
11
- ["list #{CMN} [-alN] [-f format] [-o offset] [-L limit]",
11
+ ["list #{CMN} [-alN] [-O fields] [-f format] [-o offset] [-L limit]",
12
12
  "describe #{CMN} [-f format] [-v version] <id>",
13
13
  "import #{CMN} [-f format] <file>",
14
14
  "update #{CMN} <key=value> <id>",
@@ -27,6 +27,7 @@ class WavefrontCommandDashboard < WavefrontCommandBase
27
27
  '-l, --long list dashboards in detail',
28
28
  '-a, --all list all dashboards',
29
29
  '-o, --offset=n start list from nth dashboard or revision',
30
+ '-O, --fields=F1,F2,... only show given fields',
30
31
  '-L, --limit=COUNT number of dashboards or revisions to list',
31
32
  '-v, --version=INTEGER version of dashboard',
32
33
  '-b, --brief do not show dashboard names',
@@ -16,9 +16,9 @@ class WavefrontCommandDerivedmetric < WavefrontCommandBase
16
16
  end
17
17
 
18
18
  def _commands
19
- ["list #{CMN} [-al] [-f format] [-o offset] [-L limit]",
19
+ ["list #{CMN} [-al] [-O fields] [-f format] [-o offset] [-L limit]",
20
20
  "describe #{CMN} [-f format] [-v version] <id>",
21
- "create #{CMN} [-d description] [-T tag...] [-O] [-i interval] " \
21
+ "create #{CMN} [-d description] [-T tag...] [-b] [-i interval] " \
22
22
  '[-r range] <name> <query>',
23
23
  "import #{CMN} [-f format] <file>",
24
24
  "update #{CMN} <key=value> <id>",
@@ -35,10 +35,11 @@ class WavefrontCommandDerivedmetric < WavefrontCommandBase
35
35
  '-a, --all list all derived metrics',
36
36
  '-o, --offset=n start list from nth derived metrics or ' \
37
37
  'revision',
38
+ '-O, --fields=F1,F2,... only show given fields',
38
39
  '-L, --limit=COUNT number of derived metrics or revisions to ' \
39
40
  'list',
40
41
  '-v, --version=INTEGER version of derived metrics',
41
- '-O, --obsolete include obsolete metrics',
42
+ '-b, --obsolete include obsolete metrics',
42
43
  '-T, --ctag=STRING add customer tag',
43
44
  '-d, --desc=STRING additional information about query',
44
45
  '-i, --interval=INTEGER execute query every n minutes [default: 1]',
@@ -8,8 +8,8 @@ class WavefrontCommandEvent < WavefrontCommandBase
8
8
  end
9
9
 
10
10
  def _commands
11
- ["list #{CMN} [-l] [-f format] [-s start] [-e end] [-L limit] " \
12
- '[-o cursor]',
11
+ ["list #{CMN} [-l] [-O fields] [-f format] [-s start] [-e end] " \
12
+ '[-L limit] [-o cursor]',
13
13
  "describe #{CMN} [-f format] <id>",
14
14
  "create #{CMN} [-d description] [-s time] [-i | -e time] " \
15
15
  '[-S severity] [-T type] [-H host...] [-g tag...] [-N] <event>',
@@ -27,6 +27,7 @@ class WavefrontCommandEvent < WavefrontCommandBase
27
27
  [common_options,
28
28
  '-l, --long list events in detail',
29
29
  '-o, --cursor=EVENT start listing from given event',
30
+ '-O, --fields=F1,F2,... only show given fields',
30
31
  '-L, --limit=COUNT number of events to list',
31
32
  '-s, --start=TIME time at which event begins',
32
33
  '-e, --end=TIME time at which event ends',
@@ -8,7 +8,7 @@ class WavefrontCommandIntegration < WavefrontCommandBase
8
8
  end
9
9
 
10
10
  def _commands
11
- ["list #{CMN} [-al] [-f format] [-o offset] [-L limit]",
11
+ ["list #{CMN} [-al] [-O fields] [-f format] [-o offset] [-L limit]",
12
12
  "describe #{CMN} [-f format] <id>",
13
13
  "install #{CMN} <id>",
14
14
  "uninstall #{CMN} <id>",
@@ -24,10 +24,11 @@ class WavefrontCommandIntegration < WavefrontCommandBase
24
24
 
25
25
  def _options
26
26
  [common_options,
27
- '-l, --long list cloud integrations in detail',
28
- '-a, --all list all cloud integrations',
29
- '-o, --offset=n start from nth cloud integration',
30
- '-L, --limit=COUNT number of cloud integrations to list',
31
- '-f, --format=STRING output format']
27
+ '-l, --long list cloud integrations in detail',
28
+ '-a, --all list all cloud integrations',
29
+ '-o, --offset=n start from nth cloud integration',
30
+ '-O, --fields=F1,F2,... only show given fields',
31
+ '-L, --limit=COUNT number of cloud integrations to list',
32
+ '-f, --format=STRING output format']
32
33
  end
33
34
  end
@@ -16,7 +16,7 @@ class WavefrontCommandLink < WavefrontCommandBase
16
16
  end
17
17
 
18
18
  def _commands
19
- ["list #{CMN} [-al] [-f format] [-o offset] [-L limit]",
19
+ ["list #{CMN} [-al] [-O fields] [-f format] [-o offset] [-L limit]",
20
20
  "describe #{CMN} [-f format] <id>",
21
21
  "create #{CMN} [-m regex] [-s regex] [-p str=regex...] <name> " \
22
22
  '<description> <template>',
@@ -31,6 +31,7 @@ class WavefrontCommandLink < WavefrontCommandBase
31
31
  '-l, --long list external links in detail',
32
32
  '-a, --all list all external links',
33
33
  '-o, --offset=n start from nth external link',
34
+ '-O, --fields=F1,F2,... only show given fields',
34
35
  '-L, --limit=COUNT number of external link to list',
35
36
  '-m, --metric-regex=REGEX metric filter regular expression',
36
37
  '-s, --source-regex=REGEX source filter regular expression',
@@ -8,7 +8,7 @@ class WavefrontCommandMessage < WavefrontCommandBase
8
8
  end
9
9
 
10
10
  def _commands
11
- ["list #{CMN} [-al] [-f format] [-o offset] [-L limit]",
11
+ ["list #{CMN} [-al] [-O fields] [-f format] [-o offset] [-L limit]",
12
12
  "mark #{CMN} [-f format] <id>"]
13
13
  end
14
14
 
@@ -16,6 +16,7 @@ class WavefrontCommandMessage < WavefrontCommandBase
16
16
  [common_options,
17
17
  '-l, --long list messages in detail',
18
18
  '-o, --offset=n start from nth message',
19
+ '-O, --fields=F1,F2,... only show given fields',
19
20
  '-L, --limit=COUNT number of messages to list',
20
21
  '-a, --all list all messages, not just unread',
21
22
  '-f, --format=STRING output format']
@@ -8,7 +8,7 @@ class WavefrontCommandNotificant < WavefrontCommandBase
8
8
  end
9
9
 
10
10
  def _commands
11
- ["list #{CMN} [-al] [-f format] [-o offset] [-L limit]",
11
+ ["list #{CMN} [-al] [-O fields] [-f format] [-o offset] [-L limit]",
12
12
  "describe #{CMN} [-f format] <id>",
13
13
  "import #{CMN} <file>",
14
14
  "delete #{CMN} <id>",
@@ -22,6 +22,7 @@ class WavefrontCommandNotificant < WavefrontCommandBase
22
22
  '-l, --long list alert targets in detail',
23
23
  '-a, --all list all alert targets',
24
24
  '-o, --offset=n start from nth alert target',
25
+ '-O, --fields=F1,F2,... only show given fields',
25
26
  '-f, --format=STRING output format',
26
27
  '-L, --limit=COUNT number of alert targets to list']
27
28
  end
@@ -8,7 +8,7 @@ class WavefrontCommandProxy < WavefrontCommandBase
8
8
  end
9
9
 
10
10
  def _commands
11
- ["list #{CMN} [-al] [-f format] [-o offset] [-L limit]",
11
+ ["list #{CMN} [-al] [-O fields] [-f format] [-o offset] [-L limit]",
12
12
  "describe #{CMN} [-f format] <id>",
13
13
  "delete #{CMN} <id>",
14
14
  "undelete #{CMN} <id>",
@@ -22,6 +22,7 @@ class WavefrontCommandProxy < WavefrontCommandBase
22
22
  '-l, --long list proxies in detail',
23
23
  '-a, --all list all proxies',
24
24
  '-o, --offset=n start from nth proxy',
25
+ '-O, --fields=F1,F2,... only show given fields',
25
26
  '-f, --format=STRING output format',
26
27
  '-L, --limit=COUNT number of proxies to list']
27
28
  end
@@ -16,7 +16,7 @@ class WavefrontCommandSavedsearch < WavefrontCommandBase
16
16
  end
17
17
 
18
18
  def _commands
19
- ["list #{CMN} [-al] [-f format] [-o offset] [-L limit]",
19
+ ["list #{CMN} [-al] [-O fields] [-f format] [-o offset] [-L limit]",
20
20
  "describe #{CMN} [-f format] <id>",
21
21
  "delete #{CMN} <id>",
22
22
  "import #{CMN} <file>",
@@ -28,6 +28,7 @@ class WavefrontCommandSavedsearch < WavefrontCommandBase
28
28
  '-l, --long list saved searches in detail',
29
29
  '-a, --all list all saved searches',
30
30
  '-o, --offset=n start from nth saved search',
31
+ '-O, --fields=F1,F2,... only show given fields',
31
32
  '-L, --limit=COUNT number of saved searches to list',
32
33
  '-f, --format=STRING output format']
33
34
  end
@@ -8,7 +8,7 @@ class WavefrontCommandSource < WavefrontCommandBase
8
8
  end
9
9
 
10
10
  def _commands
11
- ["list #{CMN} [-l] [-f format] [-o cursor] [-L limit] [-a]",
11
+ ["list #{CMN} [-l] [-O fields] [-f format] [-o cursor] [-L limit] [-a]",
12
12
  "describe #{CMN} [-f format] <id>",
13
13
  "description set #{CMN} <id> <description>",
14
14
  "description clear #{CMN} <id>",
@@ -19,10 +19,11 @@ class WavefrontCommandSource < WavefrontCommandBase
19
19
 
20
20
  def _options
21
21
  [common_options,
22
- '-l, --long list sources in detail',
23
- '-o, --cursor=SOURCE start list given source',
24
- '-L, --limit=COUNT number of sources to list',
25
- '-a, --all list all sources, including cluster',
26
- '-f, --format=STRING output format']
22
+ '-l, --long list sources in detail',
23
+ '-o, --cursor=SOURCE start list given source',
24
+ '-O, --fields=F1,F2,... only show given fields',
25
+ '-L, --limit=COUNT number of sources to list',
26
+ '-a, --all list all sources, including cluster',
27
+ '-f, --format=STRING output format']
27
28
  end
28
29
  end
@@ -8,7 +8,7 @@ class WavefrontCommandUser < WavefrontCommandBase
8
8
  end
9
9
 
10
10
  def _commands
11
- ["list #{CMN} [-l]",
11
+ ["list #{CMN} [-l] [-O fields]",
12
12
  "describe #{CMN} [-f format] <id>",
13
13
  "delete #{CMN} <id>",
14
14
  "import #{CMN} <file>",
@@ -19,6 +19,7 @@ class WavefrontCommandUser < WavefrontCommandBase
19
19
  def _options
20
20
  [common_options,
21
21
  '-l, --long list users in detail',
22
+ '-O, --fields=F1,F2,... only show given fields',
22
23
  '-f, --format=STRING output format']
23
24
  end
24
25
  end
@@ -8,7 +8,7 @@ class WavefrontCommandWebhook < WavefrontCommandBase
8
8
  end
9
9
 
10
10
  def _commands
11
- ["list #{CMN} [-al] [-f format] [-o offset] [-L limit]",
11
+ ["list #{CMN} [-al] [-O fields] [-f format] [-o offset] [-L limit]",
12
12
  "describe #{CMN} [-f format] <id>",
13
13
  "delete #{CMN} <id>",
14
14
  "import #{CMN} <file>",
@@ -21,6 +21,7 @@ class WavefrontCommandWebhook < WavefrontCommandBase
21
21
  '-l, --long list webhooks in detail',
22
22
  '-a, --all list all webhooks',
23
23
  '-o, --offset=n start list from nth webhook',
24
+ '-O, --fields=F1,F2,... only show given fields',
24
25
  '-L, --limit=COUNT number of webhooks to list',
25
26
  '-f, --format=STRING output format']
26
27
  end
@@ -16,7 +16,7 @@ class WavefrontCommandWindow < WavefrontCommandBase
16
16
  end
17
17
 
18
18
  def _commands
19
- ["list #{CMN} [-al] [-f format] [-o offset] [-L limit]",
19
+ ["list #{CMN} [-al] [-O fields] [-f format] [-o offset] [-L limit]",
20
20
  "describe #{CMN} [-f format] <id>",
21
21
  "create #{CMN} -d reason [-s time] [-e time] " \
22
22
  '[-A alert_tag...] [-T host_tag...] [-H host...] <title>',
@@ -32,16 +32,17 @@ class WavefrontCommandWindow < WavefrontCommandBase
32
32
 
33
33
  def _options
34
34
  [common_options,
35
- '-l, --long list maintenance windows in detail',
36
- '-a, --all list all maintenance windows',
37
- '-o, --offset=n start from nth maintenance window',
38
- '-L, --limit=COUNT number of maintenance windows to list',
39
- '-d, --desc=STRING reason for maintenance window',
40
- '-s, --start=TIME time at which window begins',
41
- '-e, --end=TIME time at which window ends',
42
- '-A, --atag=STRING alert tag to which window applies',
43
- '-H, --host=STRING host to which window applies',
44
- '-T, --htag=STRING host tag to which window applies',
45
- '-f, --format=STRING output format']
35
+ '-l, --long list maintenance windows in detail',
36
+ '-a, --all list all maintenance windows',
37
+ '-o, --offset=n start from nth maintenance window',
38
+ '-O, --fields=F1,F2,... only show given fields',
39
+ '-L, --limit=COUNT number of maintenance windows to list',
40
+ '-d, --desc=STRING reason for maintenance window',
41
+ '-s, --start=TIME time at which window begins',
42
+ '-e, --end=TIME time at which window ends',
43
+ '-A, --atag=STRING alert tag to which window applies',
44
+ '-H, --host=STRING host to which window applies',
45
+ '-T, --htag=STRING host tag to which window applies',
46
+ '-f, --format=STRING output format']
46
47
  end
47
48
  end
@@ -55,21 +55,32 @@ module WavefrontDisplay
55
55
  #
56
56
  def run_list
57
57
  if options[:long]
58
+ @data = filter_data(data, filter_fields_as_arr) if options[:fields]
58
59
  do_list
60
+ elsif options[:fields]
61
+ do_list_fields
59
62
  else
60
63
  do_list_brief
61
64
  end
62
65
  end
63
66
 
67
+ # @return [Array[Hash]] modified version of data. Each hash will
68
+ # contain only the fields given in `fields`, in the given
69
+ # order
70
+ # @param data [Array[Hash]]
71
+ # @param fields [Array]
72
+ #
73
+ def filter_data(data, fields)
74
+ data.map! do |d|
75
+ fields.each_with_object({}) { |f, a| a[f] = d[f] if d.key?(f) }
76
+ end
77
+ end
78
+
64
79
  # Choose the correct search handler. The user can specifiy a long
65
80
  # listing with the --long options.
66
81
  #
67
82
  def run_search
68
- if options[:long]
69
- do_search
70
- else
71
- do_search_brief
72
- end
83
+ options[:long] ? do_search : do_search_brief
73
84
  end
74
85
 
75
86
  # Display classes can provide a do_method_code() method, which
@@ -150,6 +161,12 @@ module WavefrontDisplay
150
161
  .downcase
151
162
  end
152
163
 
164
+ # @return [Array] filter fields from -O option
165
+ #
166
+ def filter_fields_as_arr
167
+ options[:fields].split(',')
168
+ end
169
+
153
170
  # The following do_ methods are default handlers called
154
171
  # following their namesake operation in the corresponding
155
172
  # WavefrontCli class. They can be overriden in the inheriting
@@ -159,6 +176,10 @@ module WavefrontDisplay
159
176
  long_output
160
177
  end
161
178
 
179
+ def do_list_fields
180
+ multicolumn(*filter_fields_as_arr.map(&:to_sym))
181
+ end
182
+
162
183
  def do_list_brief
163
184
  multicolumn(:id, :name)
164
185
  end
@@ -1 +1 @@
1
- WF_CLI_VERSION = '2.16.2'.freeze
1
+ WF_CLI_VERSION = '2.17.0'.freeze
@@ -11,6 +11,6 @@ require_relative 'base_spec'
11
11
  class WavefrontCommmandAlertTest < WavefrontCommmandBaseTest
12
12
  def setup
13
13
  @wf = WavefrontCommandAlert.new
14
- @col_width = 21
14
+ @col_width = 22
15
15
  end
16
16
  end
@@ -112,7 +112,7 @@ class WavefrontCommmandBaseTest < MiniTest::Test
112
112
  end
113
113
 
114
114
  def test_option_column_width
115
- assert_equal(wf.option_column_width, col_width)
115
+ assert_equal(col_width, wf.option_column_width)
116
116
  end
117
117
 
118
118
  def test_postscript
@@ -8,7 +8,7 @@ require_relative 'base_spec'
8
8
  class WavefrontCommmandCloudIntegrationTest < WavefrontCommmandBaseTest
9
9
  def setup
10
10
  @wf = WavefrontCommandCloudintegration.new
11
- @col_width = 19
11
+ @col_width = 22
12
12
  end
13
13
 
14
14
  def word
@@ -11,6 +11,6 @@ require_relative 'base_spec'
11
11
  class WavefrontCommmandDashboardTest < WavefrontCommmandBaseTest
12
12
  def setup
13
13
  @wf = WavefrontCommandDashboard.new
14
- @col_width = 21
14
+ @col_width = 22
15
15
  end
16
16
  end
@@ -11,6 +11,6 @@ require_relative 'base_spec'
11
11
  class WavefrontCommmandMessageTest < WavefrontCommmandBaseTest
12
12
  def setup
13
13
  @wf = WavefrontCommandMessage.new
14
- @col_width = 19
14
+ @col_width = 22
15
15
  end
16
16
  end
@@ -11,6 +11,6 @@ require_relative 'base_spec'
11
11
  class WavefrontCommmandProxyTest < WavefrontCommmandBaseTest
12
12
  def setup
13
13
  @wf = WavefrontCommandProxy.new
14
- @col_width = 19
14
+ @col_width = 22
15
15
  end
16
16
  end
@@ -11,6 +11,6 @@ require_relative 'base_spec'
11
11
  class WavefrontCommmandWebhookTest < WavefrontCommmandBaseTest
12
12
  def setup
13
13
  @wf = WavefrontCommandWebhook.new
14
- @col_width = 19
14
+ @col_width = 22
15
15
  end
16
16
  end
@@ -8,7 +8,7 @@ require_relative 'base_spec'
8
8
  class WavefrontCommmandWindowTest < WavefrontCommmandBaseTest
9
9
  def setup
10
10
  @wf = WavefrontCommandWindow.new
11
- @col_width = 19
11
+ @col_width = 22
12
12
  end
13
13
 
14
14
  def word
@@ -59,7 +59,7 @@ describe "#{word} command" do
59
59
  query: 'ts(series)' },
60
60
  headers: JSON_POST_HEADERS }, k)
61
61
 
62
- cmd_to_call(word, 'create -i 3 -r 7 -O test_dm ts(series)',
62
+ cmd_to_call(word, 'create -i 3 -r 7 -b test_dm ts(series)',
63
63
  { method: :post, path: '/api/v2/derivedmetric',
64
64
  body: { minutes: 7,
65
65
  name: 'test_dm',
@@ -14,10 +14,11 @@ S_OPTIONS = { '<id>': 'abc123' }.freeze
14
14
  # Test base class for display methods
15
15
  #
16
16
  class WavefrontDisplayBaseTest < MiniTest::Test
17
- attr_reader :wf
17
+ attr_reader :wf, :wff
18
18
 
19
19
  def setup
20
20
  @wf = WavefrontDisplay::Base.new(S_DATA, S_OPTIONS)
21
+ @wff = WavefrontDisplay::Base.new(S_DATA, S_OPTIONS.merge(fields: 'id'))
21
22
  end
22
23
 
23
24
  def test_put_id_first
@@ -35,6 +36,16 @@ class WavefrontDisplayBaseTest < MiniTest::Test
35
36
  assert_equal(wf.friendly_name, 'base')
36
37
  end
37
38
 
39
+ def test_filter_data
40
+ x = [{ a: 1, b: 2, c: 3 }, { a: 10, b: 11, c: 12 }]
41
+
42
+ assert_equal([{ b: 2, a: 1 }, { b: 11, a: 10 }],
43
+ wf.filter_data(x, %i[b a]))
44
+
45
+ assert_equal([{ b: 2, a: 1 }, { b: 11, a: 10 }],
46
+ wf.filter_data(x, %i[e b a f]))
47
+ end
48
+
38
49
  def test_do_list
39
50
  out = Spy.on(wf, :long_output)
40
51
  wf.do_list
@@ -44,6 +55,14 @@ class WavefrontDisplayBaseTest < MiniTest::Test
44
55
  def test_do_list_brief
45
56
  out = Spy.on(wf, :multicolumn)
46
57
  wf.do_list_brief
58
+ assert_equal(%i[id name], out.calls.first.args)
59
+ assert out.has_been_called?
60
+ end
61
+
62
+ def test_do_list_fields
63
+ out = Spy.on(wff, :multicolumn)
64
+ wff.do_list_fields
65
+ assert_equal(%i[id], out.calls.first.args)
47
66
  assert out.has_been_called?
48
67
  end
49
68
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wavefront-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.16.2
4
+ version: 2.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Fisher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-29 00:00:00.000000000 Z
11
+ date: 2019-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -347,7 +347,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
347
347
  - !ruby/object:Gem::Version
348
348
  version: '0'
349
349
  requirements: []
350
- rubygems_version: 3.0.1
350
+ rubygems_version: 3.0.2
351
351
  signing_key:
352
352
  specification_version: 4
353
353
  summary: CLI for Wavefront API v2