choosy 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/CHANGELOG.md +8 -0
  2. data/LICENSE +2 -0
  3. data/README.markdown +102 -54
  4. data/Rakefile +27 -5
  5. data/TODO.md +5 -0
  6. data/examples/bar.rb +9 -7
  7. data/examples/foo.rb +9 -7
  8. data/examples/superfoo.rb +48 -36
  9. data/lib/VERSION.yml +6 -0
  10. data/lib/choosy/argument.rb +5 -0
  11. data/lib/choosy/base_command.rb +11 -10
  12. data/lib/choosy/command.rb +17 -1
  13. data/lib/choosy/converter.rb +5 -1
  14. data/lib/choosy/dsl/argument_builder.rb +33 -21
  15. data/lib/choosy/dsl/base_builder.rb +26 -0
  16. data/lib/choosy/dsl/base_command_builder.rb +23 -30
  17. data/lib/choosy/dsl/command_builder.rb +8 -12
  18. data/lib/choosy/dsl/option_builder.rb +14 -45
  19. data/lib/choosy/dsl/super_command_builder.rb +17 -20
  20. data/lib/choosy/errors.rb +1 -0
  21. data/lib/choosy/option.rb +19 -0
  22. data/lib/choosy/printing/base_printer.rb +231 -0
  23. data/lib/choosy/printing/color.rb +8 -5
  24. data/lib/choosy/printing/erb_printer.rb +1 -1
  25. data/lib/choosy/printing/help_printer.rb +49 -163
  26. data/lib/choosy/printing/manpage.rb +235 -0
  27. data/lib/choosy/printing/manpage_printer.rb +95 -0
  28. data/lib/choosy/printing/terminal.rb +39 -8
  29. data/lib/choosy/printing.rb +1 -0
  30. data/lib/choosy/super_command.rb +13 -4
  31. data/lib/choosy/super_parser.rb +5 -1
  32. data/lib/choosy/verifier.rb +8 -0
  33. data/lib/choosy/version.rb +64 -5
  34. data/spec/choosy/argument_spec.rb +28 -0
  35. data/spec/choosy/base_command_spec.rb +7 -3
  36. data/spec/choosy/command_spec.rb +2 -2
  37. data/spec/choosy/converter_spec.rb +3 -2
  38. data/spec/choosy/dsl/argument_builder_spec.rb +19 -8
  39. data/spec/choosy/dsl/base_builder_spec.rb +43 -0
  40. data/spec/choosy/dsl/base_command_builder_spec.rb +7 -9
  41. data/spec/choosy/dsl/commmand_builder_spec.rb +9 -1
  42. data/spec/choosy/dsl/option_builder_spec.rb +1 -65
  43. data/spec/choosy/dsl/super_command_builder_spec.rb +19 -8
  44. data/spec/choosy/option_spec.rb +68 -0
  45. data/spec/choosy/printing/base_printer_spec.rb +155 -0
  46. data/spec/choosy/printing/color_spec.rb +4 -0
  47. data/spec/choosy/printing/help_printer_spec.rb +15 -109
  48. data/spec/choosy/printing/manpage_printer_spec.rb +95 -0
  49. data/spec/choosy/printing/manpage_spec.rb +206 -0
  50. data/spec/choosy/super_command_spec.rb +7 -0
  51. data/spec/choosy/super_parser_spec.rb +9 -0
  52. data/spec/choosy/verifier_spec.rb +31 -1
  53. data/spec/choosy/version.yml +5 -0
  54. data/spec/choosy/version_spec.rb +87 -0
  55. data/spec/integration/command-C_spec.rb +23 -0
  56. data/spec/integration/supercommand-C_spec.rb +45 -0
  57. metadata +81 -78
  58. data/lib/VERSION +0 -1
@@ -0,0 +1,43 @@
1
+ require 'spec_helpers'
2
+ require 'choosy/dsl/base_builder'
3
+
4
+ module Choosy::DSL
5
+ class FakeBuilder
6
+ include BaseBuilder
7
+
8
+ attr_reader :entity
9
+ def initialize(mock)
10
+ @entity = mock
11
+ end
12
+ end
13
+
14
+ describe BaseBuilder do
15
+ describe "external access calls" do
16
+ module ExternalCaller
17
+ attr_reader :called
18
+ def call!
19
+ @called = true
20
+ end
21
+ def called?
22
+ @called ||= false
23
+ end
24
+ end
25
+
26
+ include ExternalCaller
27
+
28
+ it "should allow for external calls" do
29
+ called?.should be(false)
30
+
31
+ mock = mock()
32
+ mock.should_receive(:finalize!)
33
+ builder = FakeBuilder.new(mock)
34
+
35
+ builder.evaluate! do
36
+ call!
37
+ end
38
+
39
+ called?.should be(true)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -211,13 +211,13 @@ module Choosy::DSL
211
211
 
212
212
  it "should add the builder with the given name to the command option_builders hash" do
213
213
  @builder.option :o => {:short => '-l'}
214
- @builder.command.option_builders.should have(1).item
214
+ @builder.entity.option_builders.should have(1).item
215
215
  end
216
216
 
217
217
  it "adds the option to the listing" do
218
218
  @builder.option :o => {:short => '-l'}
219
- @builder.command.listing.should have(1).item
220
- @builder.command.listing[0].name.should eql(:o)
219
+ @builder.entity.listing.should have(1).item
220
+ @builder.entity.listing[0].name.should eql(:o)
221
221
  end
222
222
  end
223
223
  end
@@ -359,13 +359,11 @@ module Choosy::DSL
359
359
  v = @builder.version "blah"
360
360
  v.description.should eql("The version number")
361
361
  end
362
- end#version
363
362
 
364
- describe :finalize! do
365
- it "should set the printer if not already set" do
366
- @builder.finalize!
367
- @command.printer.should be_a(Choosy::Printing::HelpPrinter)
363
+ it "should set the type of the version to boolean" do
364
+ v = @builder.version "1.0"
365
+ v.cast_to.should eql(:boolean)
368
366
  end
369
- end#finalize!
367
+ end#version
370
368
  end
371
369
  end
@@ -63,7 +63,7 @@ module Choosy::DSL
63
63
  end#help
64
64
 
65
65
  describe :arguments do
66
- it "should fail if there is no block given" do
66
+ it "should not fail if there is no block given" do
67
67
  attempting {
68
68
  @builder.arguments
69
69
  }.should_not raise_error
@@ -86,6 +86,14 @@ module Choosy::DSL
86
86
  @command.arguments.validation_step.call([2, 2, 3], nil)
87
87
  }.should raise_error(RuntimeError, "called")
88
88
  end
89
+
90
+ it "should finalize the arguments" do
91
+ @builder.arguments do
92
+ metaname 'args'
93
+ end
94
+
95
+ @builder.entity.arguments.cast_to.should eql(:string)
96
+ end
89
97
  end#arguments
90
98
  end
91
99
  end
@@ -5,7 +5,7 @@ module Choosy::DSL
5
5
  describe OptionBuilder do
6
6
  before :each do
7
7
  @builder = OptionBuilder.new(:stub)
8
- @option = @builder.option
8
+ @option = @builder.entity
9
9
  end
10
10
 
11
11
  describe :name do
@@ -180,13 +180,6 @@ module Choosy::DSL
180
180
  end
181
181
  end#depends_on
182
182
 
183
- describe :only do
184
- it "should set the allowable_values for an option" do
185
- @builder.only :this, :that, :other
186
- @option.allowable_values.should eql([:this, :that, :other])
187
- end
188
- end#only
189
-
190
183
  describe :negate do
191
184
  it "should set the default negation to 'no'" do
192
185
  @builder.negate
@@ -199,13 +192,6 @@ module Choosy::DSL
199
192
  @option.negated?.should be_true
200
193
  @option.negation.should eql('non')
201
194
  end
202
-
203
- it "should set the flag string for the negated value" do
204
- @builder.flags '-s', '--short'
205
- @builder.negate
206
- @builder.finalize!
207
- @option.negated.should eql("--no-short")
208
- end
209
195
  end#negate
210
196
 
211
197
  describe :from_hash do
@@ -242,55 +228,5 @@ module Choosy::DSL
242
228
  }.should raise_error(Choosy::ConfigurationError, /Only hash arguments allowed/)
243
229
  end
244
230
  end#from_hash
245
-
246
- describe :finalize! do
247
- it "should set the arity if not already set" do
248
- @builder.short '-s'
249
- @builder.finalize!
250
- @option.arity.should eql(0..0)
251
- end
252
-
253
- it "should set the cast to :string on regular arguments" do
254
- @builder.short '-s', 'SHORT'
255
- @builder.finalize!
256
- @option.cast_to.should eql(:string)
257
- end
258
-
259
- it "should set the cast to :boolean on single flags" do
260
- @builder.short '-s'
261
- @builder.finalize!
262
- @option.cast_to.should eql(:boolean)
263
- end
264
-
265
- it "should fail when both boolean and restricted" do
266
- @builder.short '-s'
267
- @builder.only :a, :b
268
- attempting{
269
- @builder.finalize!
270
- }.should raise_error(Choosy::ConfigurationError, /boolean and restricted/)
271
- end
272
-
273
- it "should fail when the argument is negated and not boolean" do
274
- @builder.short '-s', 'SHORT'
275
- @builder.negate
276
- attempting {
277
- @builder.finalize!
278
- }.should raise_error(Choosy::ConfigurationError, /negate a non-boolean option/)
279
- end
280
-
281
- it "should fail when there is no long boolean option name to negate" do
282
- @builder.short '-s'
283
- @builder.negate
284
- attempting {
285
- @builder.finalize!
286
- }.should raise_error(Choosy::ConfigurationError, /long flag is required for negation/)
287
- end
288
-
289
- it "should set the default value for booleans if not already set" do
290
- @builder.short '-s'
291
- @builder.finalize!
292
- @option.default_value.should be(false)
293
- end
294
- end#finalize!
295
231
  end
296
232
  end
@@ -38,6 +38,17 @@ module Choosy::DSL
38
38
  @builder.command cmd
39
39
  @command.listing[0].should be(cmd)
40
40
  end
41
+
42
+ it "should set the parent command on new commands" do
43
+ cmd = @builder.command :foo
44
+ cmd.parent.should be(@command)
45
+ end
46
+
47
+ it "should set the parent command on existing commands" do
48
+ cmd = Choosy::Command.new :foo
49
+ @builder.command cmd
50
+ cmd.parent.should be(@command)
51
+ end
41
52
  end
42
53
 
43
54
  describe :parsimonious do
@@ -58,17 +69,17 @@ module Choosy::DSL
58
69
  end
59
70
  end
60
71
 
61
- describe "standard options" do
62
- it "should also be able to set flags" do
63
- o = @builder.boolean :count, "The count"
64
- @command.option_builders[:count].option.name.should eql(:count)
72
+ describe :default do
73
+ it "should set the default command" do
74
+ @builder.default :foo
75
+ @command.default_command.should eql(:foo)
65
76
  end
66
77
  end
67
78
 
68
- describe :finalize! do
69
- it "should set the metaname if not already set" do
70
- @builder.finalize!
71
- @command.metaname.should eql('COMMAND')
79
+ describe "standard options" do
80
+ it "should also be able to set flags" do
81
+ o = @builder.boolean :count, "The count"
82
+ @command.option_builders[:count].entity.name.should eql(:count)
72
83
  end
73
84
  end
74
85
 
@@ -0,0 +1,68 @@
1
+ require 'spec_helpers'
2
+ require 'choosy/option'
3
+
4
+ module Choosy
5
+ describe Option do
6
+ before :each do
7
+ @option = Option.new(:option)
8
+ end
9
+
10
+ describe :negated do
11
+ it "should format the long name correctly" do
12
+ @option.long_flag = "--long"
13
+ @option.negation = 'no'
14
+ @option.negated.should eql("--no-long")
15
+ end
16
+ end
17
+
18
+ describe :finalize! do
19
+ it "should set the arity if not already set" do
20
+ @option.short_flag = '-s'
21
+ @option.finalize!
22
+ @option.arity.should eql(0..0)
23
+ end
24
+
25
+ it "should set the cast to :string on regular arguments" do
26
+ @option.single!
27
+ @option.finalize!
28
+ @option.cast_to.should eql(:string)
29
+ end
30
+
31
+ it "should set the cast to :boolean on single flags" do
32
+ @option.finalize!
33
+ @option.cast_to.should eql(:boolean)
34
+ end
35
+
36
+ it "should fail when both boolean and restricted" do
37
+ @option.short_flag = '-s'
38
+ @option.allowable_values = [:a, :b]
39
+ attempting{
40
+ @option.finalize!
41
+ }.should raise_error(Choosy::ConfigurationError, /boolean and restricted/)
42
+ end
43
+
44
+ it "should fail when the argument is negated and not boolean" do
45
+ @option.long_flag = '--long'
46
+ @option.negation = 'un'
47
+ @option.single!
48
+ attempting {
49
+ @option.finalize!
50
+ }.should raise_error(Choosy::ConfigurationError, /negate a non-boolean option/)
51
+ end
52
+
53
+ it "should fail when there is no long boolean option name to negate" do
54
+ @option.short_flag = '-s'
55
+ @option.negation = 'un'
56
+ attempting {
57
+ @option.finalize!
58
+ }.should raise_error(Choosy::ConfigurationError, /long flag is required for negation/)
59
+ end
60
+
61
+ it "should set the default value for booleans if not already set" do
62
+ @option.short_flag = '-s'
63
+ @option.finalize!
64
+ @option.default_value.should be(false)
65
+ end
66
+ end#finalize!
67
+ end
68
+ end
@@ -0,0 +1,155 @@
1
+ require 'spec_helpers'
2
+ require 'choosy/printing/base_printer'
3
+ require 'choosy/command'
4
+ require 'choosy/super_command'
5
+
6
+ module Choosy::Printing
7
+ describe BasePrinter do
8
+ before :each do
9
+ @s = Choosy::SuperCommand.new(:super)
10
+ @sb = @s.builder
11
+ @c = Choosy::Command.new(:cmd, @s)
12
+ @cb = @c.builder
13
+ @p = BasePrinter.new({})
14
+ end
15
+
16
+ describe "for the usage line" do
17
+ it "should format a full boolean option" do
18
+ o = @cb.boolean :bold, "bold"
19
+ @p.usage_option(o).should eql("[-b|--bold]")
20
+ end
21
+
22
+ it "should format a partial boolean option" do
23
+ o = @cb.boolean_ :bold, "bold"
24
+ @p.usage_option(o).should eql('[--bold]')
25
+ end
26
+
27
+ it "should format a short boolean option" do
28
+ o = @cb.option :bold do
29
+ short '-b'
30
+ end
31
+ @p.usage_option(o).should eql('[-b]')
32
+ end
33
+
34
+ it "should format a negation of a boolean option" do
35
+ o = @cb.boolean :bold, "Bold!!" do
36
+ negate 'un'
37
+ end
38
+ @p.usage_option(o).should eql('[-b|--bold|--un-bold]')
39
+ end
40
+
41
+ it "should format a full single option" do
42
+ o = @cb.single :color, "color"
43
+ @p.usage_option(o).should eql('[-c|--color=COLOR]')
44
+ end
45
+
46
+ it "should format a parial boolean option" do
47
+ o = @cb.single_ :color, "color"
48
+ @p.usage_option(o).should eql('[--color=COLOR]')
49
+ end
50
+
51
+ it "shoudl format a full multiple option" do
52
+ o = @cb.multiple :colors, "c"
53
+ @p.usage_option(o).should eql('[-c|--colors COLORS+]')
54
+ end
55
+
56
+ it "should format a partial multiple option" do
57
+ o = @cb.multiple_ :colors, "c"
58
+ @p.usage_option(o).should eql('[--colors COLORS+]')
59
+ end
60
+ end
61
+
62
+ describe "for the option line" do
63
+ it "should format a full boolean option" do
64
+ o = @cb.boolean :bold, "b"
65
+ @p.regular_option(o).should eql('-b, --bold')
66
+ end
67
+
68
+ it "should format a partial boolean option" do
69
+ o = @cb.boolean_ :bold, "b"
70
+ @p.regular_option(o).should eql(' --bold')
71
+ end
72
+
73
+ it "should format a short boolean option" do
74
+ o = @cb.option :bold do |b|
75
+ b.short '-b'
76
+ end
77
+
78
+ @p.regular_option(o).should eql('-b')
79
+ end
80
+
81
+ it "should format a negation of an option" do
82
+ o = @cb.boolean :bold, "Bold" do
83
+ negate 'un'
84
+ end
85
+
86
+ @p.regular_option(o).should eql('-b, --[un-]bold')
87
+ end
88
+
89
+ it "should format a full single option" do
90
+ o = @cb.single :color, "color"
91
+ @p.regular_option(o).should eql('-c, --color COLOR')
92
+ end
93
+
94
+ it "should format a partial single option" do
95
+ o = @cb.single_ :color, "color"
96
+ @p.regular_option(o).should eql(' --color COLOR')
97
+ end
98
+
99
+ it "should format a full multiple option" do
100
+ o = @cb.multiple :colors, "colors"
101
+ @p.regular_option(o).should eql('-c, --colors COLORS+')
102
+ end
103
+
104
+ it "should format a partial multiple option" do
105
+ o = @cb.multiple_ :colors, "colors"
106
+ @p.regular_option(o).should eql(' --colors COLORS+')
107
+ end
108
+ end
109
+
110
+ describe "formatting the command name" do
111
+ it "should format the name with the supercommand" do
112
+ @p.command_name(@c).should eql('super cmd')
113
+ end
114
+
115
+ it "should format the command" do
116
+ @p.command_name(Choosy::Command.new(:name)).should eql('name')
117
+ end
118
+
119
+ it "should format the super command" do
120
+ @p.command_name(@s).should eql('super')
121
+ end
122
+ end
123
+
124
+ describe "formatting the full usage" do
125
+ describe "for commands" do
126
+ it "should add the default metaname" do
127
+ @p.usage_wrapped(@c).should eql(['super cmd'])
128
+ end
129
+
130
+ it "should add an option if given" do
131
+ @cb.boolean :bold, "Bold?"
132
+ @p.usage_wrapped(@c).should eql(['super cmd [-b|--bold]'])
133
+ end
134
+
135
+ it "should add several options and wrap each line" do
136
+ @cb.integer :bold, "bold"
137
+ @cb.integer :long_method, "long"
138
+ @cb.integer :here_it_goes, "here"
139
+ @p.usage_wrapped(@c, ' ', 40).should eql(
140
+ ['super cmd [-b|--bold=BOLD]',
141
+ ' [-l|--long-method=LONG_METHOD]',
142
+ ' [-h|--here-it-goes=HERE_IT_GOES]'])
143
+ end
144
+
145
+ it "should add the metaname" do
146
+ @cb.arguments do
147
+ metaname 'CMDS'
148
+ end
149
+ @p.usage_wrapped(@c).should eql(['super cmd CMDS'])
150
+ end
151
+ end
152
+ end
153
+ end
154
+ end
155
+
@@ -84,5 +84,9 @@ module Choosy::Printing
84
84
  it "should be able to format multiple items" do
85
85
  @c.multiple("this", [:red, :blink]).should eql("\e[5m\e[31mthis\e[0m")
86
86
  end
87
+
88
+ it "should keep multiple colors without a reset if the string is nil" do
89
+ @c.multiple(nil, [:red, :blink]).should eql("\e[5m\e[31m")
90
+ end
87
91
  end
88
92
  end
@@ -39,51 +39,51 @@ module Choosy::Printing
39
39
  @h = @s.printer
40
40
  end
41
41
 
42
- describe :print_usage do
42
+ describe :format_prologue do
43
43
  it "should know how to format a regular command" do
44
44
  @h.color.disable!
45
45
  @h.columns = 60
46
- @h.print_usage(@c)
46
+ @h.format_prologue(@c)
47
47
 
48
48
  @h.buffer.should eql("Usage: foo [-e|--evaluate] [-c|--count=COUNT] [--debug]
49
- [--version] [-h|--help] FOOS\n")
49
+ [--version] [-h|--help] FOOS\n\n")
50
50
  end
51
51
 
52
52
  it "should know how to format a super command" do
53
53
  @h.color.disable!
54
54
  @h.columns = 60
55
- @h.print_usage(@s)
55
+ @h.format_prologue(@s)
56
56
 
57
- @h.buffer.should eql("Usage: super [-b|--bold] CMDS\n")
57
+ @h.buffer.should eql("Usage: super [-b|--bold] CMDS\n\n")
58
58
  end
59
59
  end
60
60
 
61
61
  it "should write a header, properly colored" do
62
- @h.print_header("option")
62
+ @h.format_header("option")
63
63
  @h.buffer.should eql("\e[34m\e[1moption\e[0m")
64
64
  end
65
65
 
66
66
  it "should print out a formatted header" do
67
- @h.print_element(@c.listing[0])
68
- @h.buffer.should eql("\n\e[34m\e[1mDESCRIPTION\e[0m\n")
67
+ @h.format_element(@c.listing[0])
68
+ @h.buffer.should eql("\n\e[34m\e[1mDESCRIPTION\e[0m\n\n")
69
69
  end
70
70
 
71
71
  it "should print out a formatting element correctly" do
72
- @h.print_element(@c.listing[1])
73
- @h.buffer.should eql("\n This is a description of this command that should span\n")
72
+ @h.format_element(@c.listing[1])
73
+ @h.buffer.should eql(" This is a description of this command that should span\n\n")
74
74
  end
75
75
 
76
76
  it "should wrap lines in a paragraph correctly" do
77
77
  @h.columns = 70
78
- @h.print_element(@c.listing[2])
79
- @h.buffer.should eql("\n Multiple lines and carry itself beyond the average line length when
78
+ @h.format_element(@c.listing[2])
79
+ @h.buffer.should eql(" Multiple lines and carry itself beyond the average line length when
80
80
  actually called out from the unit tests itself so that we can
81
- correctly guage the line wrapping.\n")
81
+ correctly guage the line wrapping.\n\n")
82
82
  end
83
83
 
84
84
  it "should print out an option on multiple lines" do
85
85
  @h.columns = 70
86
- @h.print_option(@c.listing[4], '-e, --evaluate', ' ' * 20)
86
+ @h.format_option(@c.listing[4], '-e, --evaluate', ' ' * 20)
87
87
  @h.buffer.should eql(' -e, --evaluate The evaluation of some boolean something or other
88
88
  that really should span at least 3 lines of
89
89
  continuous text for testing the output of the
@@ -93,104 +93,10 @@ module Choosy::Printing
93
93
 
94
94
  it "should print out any commands that are present" do
95
95
  @h.columns = 70
96
- @h.print_command(@c, 'foo', ' ')
96
+ @h.format_command(@c, 'foo', ' ')
97
97
  @h.buffer.should eql(" foo This is a fairly long summary that should wrap around the
98
98
  whole screen at least once, so that I can test whether it's
99
99
  properly formatted\n")
100
100
  end
101
-
102
- describe "for the usage line" do
103
- it "should format a full boolean option" do
104
- o = @b.boolean :bold, "bold"
105
- @h.usage_option(o).should eql("[-b|--bold]")
106
- end
107
-
108
- it "should format a partial boolean option" do
109
- o = @b.boolean_ :bold, "bold"
110
- @h.usage_option(o).should eql('[--bold]')
111
- end
112
-
113
- it "should format a short boolean option" do
114
- o = @b.option :bold do
115
- short '-b'
116
- end
117
- @h.usage_option(o).should eql('[-b]')
118
- end
119
-
120
- it "should format a negation of a boolean option" do
121
- o = @b.boolean :bold, "Bold!!" do
122
- negate 'un'
123
- end
124
- @h.usage_option(o).should eql('[-b|--bold|--un-bold]')
125
- end
126
-
127
- it "should format a full single option" do
128
- o = @b.single :color, "color"
129
- @h.usage_option(o).should eql('[-c|--color=COLOR]')
130
- end
131
-
132
- it "should format a parial boolean option" do
133
- o = @b.single_ :color, "color"
134
- @h.usage_option(o).should eql('[--color=COLOR]')
135
- end
136
-
137
- it "shoudl format a full multiple option" do
138
- o = @b.multiple :colors, "c"
139
- @h.usage_option(o).should eql('[-c|--colors COLORS+]')
140
- end
141
-
142
- it "should format a partial multiple option" do
143
- o = @b.multiple_ :colors, "c"
144
- @h.usage_option(o).should eql('[--colors COLORS+]')
145
- end
146
- end
147
-
148
- describe "for the option line" do
149
- it "should format a full boolean option" do
150
- o = @b.boolean :bold, "b"
151
- @h.regular_option(o).should eql('-b, --bold')
152
- end
153
-
154
- it "should format a partial boolean option" do
155
- o = @b.boolean_ :bold, "b"
156
- @h.regular_option(o).should eql(' --bold')
157
- end
158
-
159
- it "should format a short boolean option" do
160
- o = @b.option :bold do |b|
161
- b.short '-b'
162
- end
163
-
164
- @h.regular_option(o).should eql('-b')
165
- end
166
-
167
- it "should format a negation of an option" do
168
- o = @b.boolean :bold, "Bold" do
169
- negate 'un'
170
- end
171
-
172
- @h.regular_option(o).should eql('-b, --[un-]bold')
173
- end
174
-
175
- it "should format a full single option" do
176
- o = @b.single :color, "color"
177
- @h.regular_option(o).should eql('-c, --color COLOR')
178
- end
179
-
180
- it "should format a partial single option" do
181
- o = @b.single_ :color, "color"
182
- @h.regular_option(o).should eql(' --color COLOR')
183
- end
184
-
185
- it "should format a full multiple option" do
186
- o = @b.multiple :colors, "colors"
187
- @h.regular_option(o).should eql('-c, --colors COLORS+')
188
- end
189
-
190
- it "should format a partial multiple option" do
191
- o = @b.multiple_ :colors, "colors"
192
- @h.regular_option(o).should eql(' --colors COLORS+')
193
- end
194
- end
195
101
  end
196
102
  end