hammer_cli 0.19.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/bin/hammer-complete +28 -0
  3. data/config/cli_config.template.yml +2 -0
  4. data/config/hammer.completion +5 -0
  5. data/doc/commands_extension.md +12 -0
  6. data/doc/creating_commands.md +100 -0
  7. data/doc/installation.md +47 -4
  8. data/doc/installation_rpm.md +2 -2
  9. data/doc/release_notes.md +31 -6
  10. data/lib/hammer_cli.rb +1 -0
  11. data/lib/hammer_cli/abstract.rb +61 -4
  12. data/lib/hammer_cli/apipie/api_connection.rb +5 -1
  13. data/lib/hammer_cli/apipie/command.rb +3 -2
  14. data/lib/hammer_cli/apipie/option_builder.rb +15 -13
  15. data/lib/hammer_cli/apipie/option_definition.rb +9 -7
  16. data/lib/hammer_cli/bash.rb +2 -0
  17. data/lib/hammer_cli/bash/completion.rb +159 -0
  18. data/lib/hammer_cli/bash/prebuild_command.rb +21 -0
  19. data/lib/hammer_cli/command_extensions.rb +21 -1
  20. data/lib/hammer_cli/connection.rb +4 -0
  21. data/lib/hammer_cli/exception_handler.rb +11 -2
  22. data/lib/hammer_cli/full_help.rb +8 -1
  23. data/lib/hammer_cli/help/builder.rb +29 -3
  24. data/lib/hammer_cli/logger_watch.rb +1 -1
  25. data/lib/hammer_cli/main.rb +5 -3
  26. data/lib/hammer_cli/options/normalizers.rb +7 -3
  27. data/lib/hammer_cli/options/option_definition.rb +26 -6
  28. data/lib/hammer_cli/options/option_family.rb +114 -0
  29. data/lib/hammer_cli/options/predefined.rb +1 -1
  30. data/lib/hammer_cli/output/adapter/abstract.rb +1 -5
  31. data/lib/hammer_cli/output/adapter/base.rb +1 -1
  32. data/lib/hammer_cli/output/adapter/csv.rb +3 -2
  33. data/lib/hammer_cli/output/adapter/json.rb +14 -3
  34. data/lib/hammer_cli/output/adapter/silent.rb +1 -1
  35. data/lib/hammer_cli/output/adapter/table.rb +27 -8
  36. data/lib/hammer_cli/output/adapter/yaml.rb +6 -3
  37. data/lib/hammer_cli/output/output.rb +2 -4
  38. data/lib/hammer_cli/settings.rb +2 -1
  39. data/lib/hammer_cli/subcommand.rb +25 -1
  40. data/lib/hammer_cli/testing/command_assertions.rb +2 -2
  41. data/lib/hammer_cli/utils.rb +22 -0
  42. data/lib/hammer_cli/version.rb +1 -1
  43. data/locale/ca/LC_MESSAGES/hammer-cli.mo +0 -0
  44. data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
  45. data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
  46. data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
  47. data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
  48. data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
  49. data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
  50. data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
  51. data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
  52. data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
  53. data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
  54. data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
  55. data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
  56. data/test/unit/abstract_test.rb +23 -2
  57. data/test/unit/apipie/api_connection_test.rb +1 -0
  58. data/test/unit/apipie/option_builder_test.rb +8 -0
  59. data/test/unit/bash_test.rb +138 -0
  60. data/test/unit/command_extensions_test.rb +67 -49
  61. data/test/unit/exception_handler_test.rb +44 -0
  62. data/test/unit/help/builder_test.rb +22 -0
  63. data/test/unit/options/option_family_test.rb +48 -0
  64. data/test/unit/output/adapter/base_test.rb +58 -0
  65. data/test/unit/output/adapter/csv_test.rb +63 -1
  66. data/test/unit/output/adapter/json_test.rb +61 -0
  67. data/test/unit/output/adapter/table_test.rb +70 -1
  68. data/test/unit/output/adapter/yaml_test.rb +59 -0
  69. data/test/unit/output/output_test.rb +3 -3
  70. metadata +17 -6
  71. data/hammer_cli_complete +0 -13
@@ -71,13 +71,13 @@ module HammerCLI
71
71
  if heading.nil?
72
72
  ["Error: #{message}",
73
73
  "",
74
- "See: '#{command} --help'.",
74
+ "See: '#{HammerCLI.expand_invocation_path(command)} --help'.",
75
75
  ""].join("\n")
76
76
  else
77
77
  ["#{heading}:",
78
78
  " Error: #{message}",
79
79
  " ",
80
- " See: '#{command} --help'.",
80
+ " See: '#{HammerCLI.expand_invocation_path(command)} --help'.",
81
81
  ""].join("\n")
82
82
  end
83
83
  end
@@ -60,6 +60,11 @@ module HammerCLI
60
60
  STDOUT.tty?
61
61
  end
62
62
 
63
+ def self.clear_cache
64
+ cache_file = File.expand_path(HammerCLI::Settings.get(:completion_cache_file))
65
+ File.delete(cache_file) if File.exist?(cache_file)
66
+ end
67
+
63
68
  def self.interactive?
64
69
  return HammerCLI::Settings.get(:_params, :interactive) unless HammerCLI::Settings.get(:_params, :interactive).nil?
65
70
  HammerCLI::Settings.get(:ui, :interactive) != false
@@ -111,4 +116,21 @@ module HammerCLI
111
116
 
112
117
  array.insert(idx, *new_items)
113
118
  end
119
+
120
+ def self.expand_invocation_path(path)
121
+ bits = path.split(' ')
122
+ parent_command = HammerCLI::MainCommand
123
+ new_path = (bits[1..-1] || []).each_with_object([]) do |bit, names|
124
+ subcommand = parent_command.find_subcommand(bit)
125
+ next if subcommand.nil?
126
+
127
+ names << if subcommand.names.size > 1
128
+ "<#{subcommand.names.join('|')}>"
129
+ else
130
+ subcommand.names.first
131
+ end
132
+ parent_command = subcommand.subcommand_class
133
+ end
134
+ new_path.unshift(bits.first).join(' ')
135
+ end
114
136
  end
@@ -1,5 +1,5 @@
1
1
  module HammerCLI
2
2
  def self.version
3
- @version ||= Gem::Version.new "0.19.1"
3
+ @version ||= Gem::Version.new "2.2.0"
4
4
  end
5
5
  end
@@ -262,6 +262,27 @@ describe HammerCLI::AbstractCommand do
262
262
  end
263
263
 
264
264
  end
265
+
266
+ describe 'find_subcommand' do
267
+ it 'should find by full name' do
268
+ main_cmd.find_subcommand('some_command').wont_be_nil
269
+ end
270
+
271
+ it 'should find by partial name' do
272
+ main_cmd.find_subcommand('some_').wont_be_nil
273
+ end
274
+
275
+ it 'should not find by wrong name' do
276
+ main_cmd.find_subcommand('not_existing').must_be_nil
277
+ end
278
+
279
+ it 'should raise if more than one were found' do
280
+ main_cmd.subcommand('pong', 'description', Subcommand2)
281
+ proc do
282
+ main_cmd.find_subcommand('p')
283
+ end.must_raise HammerCLI::CommandConflict
284
+ end
285
+ end
265
286
  end
266
287
 
267
288
  describe "options" do
@@ -413,7 +434,7 @@ describe HammerCLI::AbstractCommand do
413
434
  class CmdName2 < CmdName1
414
435
  end
415
436
 
416
- CmdName2.command_name.must_equal 'cmd'
437
+ CmdName2.command_name.must_equal ['cmd']
417
438
  end
418
439
 
419
440
  it "should inherit output definition" do
@@ -525,7 +546,7 @@ describe HammerCLI::AbstractCommand do
525
546
  opt = cmd.find_option('--flag')
526
547
  opt.is_a?(HammerCLI::Options::OptionDefinition).must_equal true
527
548
  cmd.output_definition.empty?.must_equal false
528
- cmd.new({}).help.must_match(/.*text.*/)
549
+ cmd.new('', {}).help.must_match(/.*text.*/)
529
550
  end
530
551
 
531
552
  it 'should store more than one extension' do
@@ -30,6 +30,7 @@ describe HammerCLI::Apipie::ApiConnection do
30
30
  it "logs message when logger is available" do
31
31
  logger = stub()
32
32
  logger.expects(:debug).with('Apipie cache was cleared')
33
+ logger.expects(:debug).with('Completion cache was cleared')
33
34
 
34
35
  api_stub.expects(:clean_cache)
35
36
  HammerCLI::Apipie::ApiConnection.new(empty_params, :reload_cache => true, :logger => logger)
@@ -37,6 +37,14 @@ describe HammerCLI::Apipie::OptionBuilder do
37
37
  it "should set description with html tags stripped" do
38
38
  options[0].description.must_equal 'filter results'
39
39
  end
40
+
41
+ it "should build option with default family" do
42
+ options[0].family.wont_be_nil
43
+ end
44
+
45
+ it "should build parent option within default family" do
46
+ options[0].child?.must_equal false
47
+ end
40
48
  end
41
49
 
42
50
 
@@ -0,0 +1,138 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ describe HammerCLI::Bash::Completion do
4
+ describe '#complete' do
5
+ let(:dict) do
6
+ {
7
+ 'host' => {
8
+ 'create' => {
9
+ '--installed-products-attributes' => { type: :schema, schema: '"product_id=string\,product_name=string\,arch=string\,version=string, ... "' },
10
+ '--help' => { type: :flag },
11
+ '--build' => { type: :flag },
12
+ '--managed' => { type: :enum, values: %w[yes no] },
13
+ '--volume' => { type: :multienum, values: %w[first second third] },
14
+ '--config-group-ids' => { type: :list },
15
+ '--params' => { type: :key_value_list },
16
+ '--log' => { type: :file, filter: '.*\.log$' },
17
+ '--pool' => { type: :directory },
18
+ '-t' => { type: :value },
19
+ :params => [{ type: :directory }, { type: :value }, { type: :file }]
20
+ },
21
+ '--dry' => { type: :flag },
22
+ '--help' => { type: :flag },
23
+ },
24
+ '--interactive' => { type: :enum, values: %w[yes no] },
25
+ '--help' => { type: :flag },
26
+ '-h' => { type: :flag }
27
+ }
28
+ end
29
+
30
+ subject do
31
+ HammerCLI::Bash::Completion.new(JSON.load(dict.to_json))
32
+ end
33
+
34
+ it 'returns options when no input given' do
35
+ result = subject.complete('').sort
36
+ result.must_equal ['host ', '--interactive ', '--help ', '-h '].sort
37
+ end
38
+
39
+ it 'returns filtered options when partial input is given' do
40
+ result = subject.complete('-').sort
41
+ result.must_equal ['--help ', '-h ', '--interactive '].sort
42
+ end
43
+
44
+ it 'returns filtered options when partial input is given' do
45
+ result = subject.complete('host')
46
+ result.must_equal ['host ']
47
+ end
48
+
49
+ it 'returns options when subcommand is given' do
50
+ result = subject.complete('host ').sort
51
+ result.must_equal ['create ', '--help ', '--dry '].sort
52
+ end
53
+
54
+ it 'returns no options when subcommand is wrong' do
55
+ result = subject.complete('unknown -h')
56
+ result.must_equal []
57
+ end
58
+
59
+ it 'returns no options when there are no other params allowed' do
60
+ result = subject.complete('host create /tmp some /tmp extra')
61
+ result.must_equal []
62
+ end
63
+
64
+ it 'return hint for option-value pair without value' do
65
+ result = subject.complete('host create -t ')
66
+ result.must_equal ['--->', 'Add option <value>']
67
+ end
68
+
69
+ it 'return no options for option-value pair without complete value' do
70
+ result = subject.complete('host create -t x')
71
+ result.must_equal []
72
+ end
73
+
74
+ # multiple options in one subcommand
75
+ it 'allows mutiple options of the same subcommand' do
76
+ result = subject.complete('host create --build --he')
77
+ result.must_equal ['--help ']
78
+ end
79
+
80
+ # multiple options with values in one subcommand
81
+ it 'allows mutiple options with values of the same subcommand' do
82
+ result = subject.complete('host create -t value --he')
83
+ result.must_equal ['--help ']
84
+ end
85
+
86
+ # subcommand after options
87
+ it 'allows subcommand after options' do
88
+ result = subject.complete('host --dry crea')
89
+ result.must_equal ['create ']
90
+ end
91
+
92
+ describe 'completion by type' do
93
+ it 'completes :value' do
94
+ result = subject.complete('host create -t ')
95
+ result.must_equal ['--->', 'Add option <value>']
96
+ end
97
+
98
+ it 'completes :flag' do
99
+ result = subject.complete('host --h')
100
+ result.must_equal ['--help ']
101
+ end
102
+
103
+ it 'completes :schema' do
104
+ result = subject.complete('host create --installed-products-attributes ')
105
+ result.must_equal ["--->", 'Add value by following schema: "product_id=string\,product_name=string\,arch=string\,version=string, ... "']
106
+ end
107
+
108
+ it 'completes :enum' do
109
+ result = subject.complete('host create --managed ')
110
+ result.must_equal ['yes ', 'no ']
111
+ end
112
+
113
+ it 'completes :multienum' do
114
+ result = subject.complete('host create --volume ')
115
+ result.must_equal ['first', 'second', 'third']
116
+
117
+ result = subject.complete('host create --volume fir')
118
+ result.must_equal ['first']
119
+
120
+ result = subject.complete('host create --volume first,')
121
+ result.must_equal ['second', 'third']
122
+
123
+ result = subject.complete('host create --volume first,se')
124
+ result.must_equal ['first,second']
125
+ end
126
+
127
+ it 'completes :list' do
128
+ result = subject.complete('host create --config-group-ids ')
129
+ result.must_equal ['--->', 'Add comma-separated list of values']
130
+ end
131
+
132
+ it 'completes :key_value_list' do
133
+ result = subject.complete('host create --params ')
134
+ result.must_equal ['--->', 'Add comma-separated list of key=value']
135
+ end
136
+ end
137
+ end
138
+ end
@@ -23,6 +23,12 @@ describe HammerCLI::CommandExtensions do
23
23
 
24
24
  class CmdExtensions < HammerCLI::CommandExtensions
25
25
  option '--ext', 'EXT', 'ext'
26
+ option_family(
27
+ description: 'Test',
28
+ ) do
29
+ parent '--test-one', '', ''
30
+ child '--test-two', '', ''
31
+ end
26
32
  before_print do |data|
27
33
  data['key'] = 'value'
28
34
  end
@@ -64,49 +70,55 @@ describe HammerCLI::CommandExtensions do
64
70
 
65
71
  it 'should extend help only' do
66
72
  cmd.extend_with(CmdExtensions.new(only: :help))
67
- cmd.new({}).help.must_match(/.*Section.*/)
68
- cmd.new({}).help.must_match(/.*text.*/)
73
+ cmd.new('', {}).help.must_match(/.*Section.*/)
74
+ cmd.new('', {}).help.must_match(/.*text.*/)
69
75
  end
70
76
 
71
77
  it 'should extend params only' do
72
78
  cmd.extend_with(CmdExtensions.new(only: :request_params))
73
- cmd.new({}).extended_request[0].must_equal(thin: true)
74
- cmd.new({}).extended_request[1].must_equal({})
75
- cmd.new({}).extended_request[2].must_equal({})
79
+ cmd.new('', {}).extended_request[0].must_equal(thin: true)
80
+ cmd.new('', {}).extended_request[1].must_equal({})
81
+ cmd.new('', {}).extended_request[2].must_equal({})
76
82
  end
77
83
 
78
84
  it 'should extend headers only' do
79
85
  cmd.extend_with(CmdExtensions.new(only: :request_headers))
80
- cmd.new({}).extended_request[0].must_equal({})
81
- cmd.new({}).extended_request[1].must_equal(ssl: true)
82
- cmd.new({}).extended_request[2].must_equal({})
86
+ cmd.new('', {}).extended_request[0].must_equal({})
87
+ cmd.new('', {}).extended_request[1].must_equal(ssl: true)
88
+ cmd.new('', {}).extended_request[2].must_equal({})
83
89
  end
84
90
 
85
91
  it 'should extend options only' do
86
92
  cmd.extend_with(CmdExtensions.new(only: :request_options))
87
- cmd.new({}).extended_request[0].must_equal({})
88
- cmd.new({}).extended_request[1].must_equal({})
89
- cmd.new({}).extended_request[2].must_equal(with_authentication: true)
93
+ cmd.new('', {}).extended_request[0].must_equal({})
94
+ cmd.new('', {}).extended_request[1].must_equal({})
95
+ cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
90
96
  end
91
97
 
92
98
  it 'should extend params and options and headers' do
93
99
  cmd.extend_with(CmdExtensions.new(only: :request))
94
- cmd.new({}).extended_request[0].must_equal(thin: true)
95
- cmd.new({}).extended_request[1].must_equal(ssl: true)
96
- cmd.new({}).extended_request[2].must_equal(with_authentication: true)
100
+ cmd.new('', {}).extended_request[0].must_equal(thin: true)
101
+ cmd.new('', {}).extended_request[1].must_equal(ssl: true)
102
+ cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
97
103
  end
98
104
 
99
105
  it 'should extend data only' do
100
106
  cmd.extend_with(CmdExtensions.new(only: :data))
101
- cmd.new({}).help.wont_match(/.*Section.*/)
102
- cmd.new({}).help.wont_match(/.*text.*/)
107
+ cmd.new('', {}).help.wont_match(/.*Section.*/)
108
+ cmd.new('', {}).help.wont_match(/.*text.*/)
103
109
  cmd.output_definition.empty?.must_equal true
104
110
  opt = cmd.find_option('--ext')
105
111
  opt.is_a?(HammerCLI::Options::OptionDefinition).must_equal false
106
- cmd.new({}).extended_request[0].must_equal({})
107
- cmd.new({}).extended_request[1].must_equal({})
108
- cmd.new({}).extended_request[2].must_equal({})
109
- cmd.new({}).extended_data({}).must_equal('key' => 'value')
112
+ cmd.new('', {}).extended_request[0].must_equal({})
113
+ cmd.new('', {}).extended_request[1].must_equal({})
114
+ cmd.new('', {}).extended_request[2].must_equal({})
115
+ cmd.new('', {}).extended_data({}).must_equal('key' => 'value')
116
+ end
117
+
118
+ it 'should extend option family only' do
119
+ cmd.extend_with(CmdExtensions.new(only: :option_family))
120
+ cmd.output_definition.empty?.must_equal true
121
+ cmd.recognised_options.map(&:switches).flatten.must_equal ['--test-one', '--test-two', '-h', '--help']
110
122
  end
111
123
  end
112
124
 
@@ -116,9 +128,9 @@ describe HammerCLI::CommandExtensions do
116
128
  opt = cmd.find_option('--ext')
117
129
  opt.is_a?(HammerCLI::Options::OptionDefinition).must_equal false
118
130
  cmd.output_definition.empty?.must_equal false
119
- cmd.new({}).extended_request[0].must_equal(thin: true)
120
- cmd.new({}).extended_request[1].must_equal(ssl: true)
121
- cmd.new({}).extended_request[2].must_equal(with_authentication: true)
131
+ cmd.new('', {}).extended_request[0].must_equal(thin: true)
132
+ cmd.new('', {}).extended_request[1].must_equal(ssl: true)
133
+ cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
122
134
  end
123
135
 
124
136
  it 'should extend all except output' do
@@ -126,62 +138,68 @@ describe HammerCLI::CommandExtensions do
126
138
  cmd.output_definition.empty?.must_equal true
127
139
  opt = cmd.find_option('--ext')
128
140
  opt.is_a?(HammerCLI::Options::OptionDefinition).must_equal true
129
- cmd.new({}).extended_request[0].must_equal(thin: true)
130
- cmd.new({}).extended_request[1].must_equal(ssl: true)
131
- cmd.new({}).extended_request[2].must_equal(with_authentication: true)
141
+ cmd.new('', {}).extended_request[0].must_equal(thin: true)
142
+ cmd.new('', {}).extended_request[1].must_equal(ssl: true)
143
+ cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
132
144
  end
133
145
 
134
146
  it 'should extend all except help' do
135
147
  cmd.extend_with(CmdExtensions.new(except: :help))
136
- cmd.new({}).help.wont_match(/.*Section.*/)
137
- cmd.new({}).help.wont_match(/.*text.*/)
148
+ cmd.new('', {}).help.wont_match(/.*Section.*/)
149
+ cmd.new('', {}).help.wont_match(/.*text.*/)
138
150
  cmd.output_definition.empty?.must_equal false
139
151
  opt = cmd.find_option('--ext')
140
152
  opt.is_a?(HammerCLI::Options::OptionDefinition).must_equal true
141
- cmd.new({}).extended_request[0].must_equal(thin: true)
142
- cmd.new({}).extended_request[1].must_equal(ssl: true)
143
- cmd.new({}).extended_request[2].must_equal(with_authentication: true)
153
+ cmd.new('', {}).extended_request[0].must_equal(thin: true)
154
+ cmd.new('', {}).extended_request[1].must_equal(ssl: true)
155
+ cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
144
156
  end
145
157
 
146
158
  it 'should extend all except params' do
147
159
  cmd.extend_with(CmdExtensions.new(except: :request_params))
148
- cmd.new({}).extended_request[0].must_equal({})
149
- cmd.new({}).extended_request[1].must_equal(ssl: true)
150
- cmd.new({}).extended_request[2].must_equal(with_authentication: true)
160
+ cmd.new('', {}).extended_request[0].must_equal({})
161
+ cmd.new('', {}).extended_request[1].must_equal(ssl: true)
162
+ cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
151
163
  end
152
164
 
153
165
  it 'should extend all except headers' do
154
166
  cmd.extend_with(CmdExtensions.new(except: :request_headers))
155
- cmd.new({}).extended_request[0].must_equal(thin: true)
156
- cmd.new({}).extended_request[1].must_equal({})
157
- cmd.new({}).extended_request[2].must_equal(with_authentication: true)
167
+ cmd.new('', {}).extended_request[0].must_equal(thin: true)
168
+ cmd.new('', {}).extended_request[1].must_equal({})
169
+ cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
158
170
  end
159
171
 
160
172
  it 'should extend all except options' do
161
173
  cmd.extend_with(CmdExtensions.new(except: :request_options))
162
- cmd.new({}).extended_request[0].must_equal(thin: true)
163
- cmd.new({}).extended_request[1].must_equal(ssl: true)
164
- cmd.new({}).extended_request[2].must_equal({})
174
+ cmd.new('', {}).extended_request[0].must_equal(thin: true)
175
+ cmd.new('', {}).extended_request[1].must_equal(ssl: true)
176
+ cmd.new('', {}).extended_request[2].must_equal({})
165
177
  end
166
178
 
167
179
  it 'should extend all except params and options and headers' do
168
180
  cmd.extend_with(CmdExtensions.new(except: :request))
169
- cmd.new({}).extended_request[0].must_equal({})
170
- cmd.new({}).extended_request[1].must_equal({})
171
- cmd.new({}).extended_request[2].must_equal({})
181
+ cmd.new('', {}).extended_request[0].must_equal({})
182
+ cmd.new('', {}).extended_request[1].must_equal({})
183
+ cmd.new('', {}).extended_request[2].must_equal({})
172
184
  end
173
185
 
174
186
  it 'should extend all except data' do
175
187
  cmd.extend_with(CmdExtensions.new(except: :data))
176
- cmd.new({}).help.must_match(/.*Section.*/)
177
- cmd.new({}).help.must_match(/.*text.*/)
188
+ cmd.new('', {}).help.must_match(/.*Section.*/)
189
+ cmd.new('', {}).help.must_match(/.*text.*/)
178
190
  cmd.output_definition.empty?.must_equal false
179
191
  opt = cmd.find_option('--ext')
180
192
  opt.is_a?(HammerCLI::Options::OptionDefinition).must_equal true
181
- cmd.new({}).extended_request[0].must_equal(thin: true)
182
- cmd.new({}).extended_request[1].must_equal(ssl: true)
183
- cmd.new({}).extended_request[2].must_equal(with_authentication: true)
184
- cmd.new({}).extended_data({}).must_equal({})
193
+ cmd.new('', {}).extended_request[0].must_equal(thin: true)
194
+ cmd.new('', {}).extended_request[1].must_equal(ssl: true)
195
+ cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
196
+ cmd.new('', {}).extended_data({}).must_equal({})
197
+ end
198
+
199
+ it 'should extend all except option family' do
200
+ cmd.extend_with(CmdExtensions.new(except: :option_family))
201
+ cmd.output_definition.empty?.must_equal false
202
+ cmd.recognised_options.map(&:switches).flatten.must_equal ['--ext', '-h', '--help']
185
203
  end
186
204
  end
187
205