opt_parse_builder 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae59f7036ba75769d0965d67ec2b8d79c9d1965d3867898ee40b1a6e39d63395
4
- data.tar.gz: d92e59065fc880fb4b0182f4a9f3d608bc88d69333a37267f7edaae36efd41b2
3
+ metadata.gz: b030936035ec1d79b8d22024f239664a8b8bf47c7fc00ac80d7d183a49859126
4
+ data.tar.gz: 3b771b01a70ddfbf2d4109f2554558100e729cb994c464625e49b35652d364f4
5
5
  SHA512:
6
- metadata.gz: 688195cd6207f2a4dbb5aebb66851efe094a17a1e3c55d87cd38f62ffe72cc15acd665c1ad64e203abe806f8a5cb767dd4ff46123f4c521f003b70e570a883b8
7
- data.tar.gz: 97a98d23c58dbbeda7136b5399455bde1d00840c2748409f8ae85dce667d06f4b114ac7e00ea110bd5bdd8a58758af11ba0d34b975960acea67db21cc80aa325
6
+ metadata.gz: 0140ca5bf9a14f8efd29040e75902d627331ec4be3d8c89dd4010da75cf38fd1f1b55321c53e8b5ebb4aa4b6c3ba94905efe6c8249dd95aade6e670f58135c12
7
+ data.tar.gz: f7f76918a1fa34779168c0e398f9adac38b82cd51e799a99c9e28ba9f6c2bbedfa606d9221590c2a65d1652cb93ecfc0670104813ba8a541140a6ad2a0bda083
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  # Development
4
4
 
5
+ # 1.1.0 - 2025-11-28
6
+
7
+ * Add footer method for text at bottom of help output (recommended)
8
+ * Add footer: parameter to separator method
9
+ - separator(line, footer: true) - deprecated, emits warning
10
+ - separator(line, footer: false) - new positional behavior
11
+ - Provides clear migration path to v2.0.0
12
+
5
13
  # 1.0.0 - 2025-11-28
6
14
 
7
15
  * Declare API stability by bumping version to 1.0.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opt_parse_builder (1.0.0)
4
+ opt_parse_builder (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -62,7 +62,7 @@ arg_parser = OptParseBuilder.build_parser do |args|
62
62
  arg.key :verbose
63
63
  arg.on "-v", "--verbose", "Be verbose"
64
64
  end
65
- args.separator "Some explanatory text at the bottom"
65
+ args.footer "Some explanatory text at the bottom"
66
66
  end
67
67
 
68
68
  arg_values = arg_parser.parse!
@@ -262,27 +262,67 @@ Applicable builder methods:
262
262
 
263
263
  Banner text can be added to any argument.
264
264
 
265
- ## Separator only
265
+ ## Footer only
266
266
 
267
- An argument with only separator text (but see
268
- OptParseBuilder#banner for the usual way to do this). "Separator"
269
- is how OptParse describes text that appears at the bottom of the
270
- --help output.
267
+ An argument with only footer text (but see
268
+ OptParseBuilder#footer for the usual way to do this). Footer text
269
+ appears at the bottom of the --help output.
271
270
 
272
271
  OptParseBuilder.build_argument do |arg|
273
- arg.serparator "Separator text"
274
- arg.serparator "A second line of separator text"
275
- arg.serparator <<~SERPARATOR
272
+ arg.footer "Footer text at the bottom"
273
+ arg.footer "A second line of footer text"
274
+ arg.footer <<~FOOTER
276
275
  A third line
277
276
  A fourth line
278
- SERPARATOR
277
+ FOOTER
279
278
  end
280
279
 
281
280
  Applicable builder methods:
282
281
 
283
- * separator
282
+ * footer
284
283
 
285
- Separator text can be added to any argument.
284
+ Footer text can be added to any argument.
285
+
286
+ ## Positional separator
287
+
288
+ A separator that appears between options in the --help output,
289
+ useful for grouping related options.
290
+
291
+ OptParseBuilder.build_argument do |arg|
292
+ arg.key :verbose
293
+ arg.on "-v", "--verbose", "Be verbose"
294
+ arg.separator "--- Advanced options ---", footer: false
295
+ end
296
+
297
+ The separator will appear immediately after the option it's
298
+ attached to, allowing you to divide your options into sections.
299
+
300
+ Applicable builder methods:
301
+
302
+ * separator (with footer: false parameter)
303
+
304
+ ## Separator only (deprecated)
305
+
306
+ **Note:** Using `separator` without the `footer:` parameter is
307
+ deprecated in v1.1.0 and will change behavior in v2.0.0. Use
308
+ `footer` for text at the bottom, or `separator(text, footer: false)`
309
+ for positional text.
310
+
311
+ # Deprecated - emits warning
312
+ OptParseBuilder.build_argument do |arg|
313
+ arg.separator "Text at bottom"
314
+ end
315
+
316
+ # Recommended alternatives:
317
+ # For bottom text:
318
+ OptParseBuilder.build_argument do |arg|
319
+ arg.footer "Text at bottom"
320
+ end
321
+
322
+ # For positional text:
323
+ OptParseBuilder.build_argument do |arg|
324
+ arg.separator "Between options", footer: false
325
+ end
286
326
 
287
327
  ## Constant value
288
328
 
data/doc/publishing.md CHANGED
@@ -2,9 +2,9 @@ Publishing a New Release
2
2
 
3
3
  # Checklist
4
4
 
5
- * Run tests: `rake`
6
5
  * Update `lib/opt_parse_builder/version.rb`
7
6
  * Update `CHANGELOG.md` with version and date
7
+ * Run tests: `rake`
8
8
  * Commit: `git commit -am "Bump version to X.X.X"`
9
9
  * Release: `rake release`
10
10
  * Verify at https://rubygems.org/gems/opt_parse_builder
@@ -31,6 +31,10 @@ module OptParseBuilder
31
31
  []
32
32
  end
33
33
 
34
+ def footer_lines # :nodoc:
35
+ []
36
+ end
37
+
34
38
  def apply_option(_op) # :nodoc:
35
39
  end
36
40
 
@@ -16,6 +16,7 @@ module OptParseBuilder
16
16
  @operand_help_name = nil
17
17
  @banner_lines = []
18
18
  @separator_lines = []
19
+ @footer_lines = []
19
20
  end
20
21
 
21
22
  # Set the argument's key. Accepts either a string or a symbol.
@@ -115,11 +116,38 @@ module OptParseBuilder
115
116
  # may call this more than once; each call adds another line of
116
117
  # text to the separator.
117
118
  #
119
+ # The footer: parameter controls where the text appears:
120
+ # * footer: true (default in v1.x) - text appears at bottom
121
+ # (DEPRECATED: use footer method instead)
122
+ # * footer: false - text appears positionally between options
123
+ # (will be default in v2.0.0)
124
+ #
118
125
  # Any type of argument may have separator text.
119
126
  #
120
- # See also OptParseBuilder#separator
121
- def separator(line)
122
- @separator_lines << line
127
+ # See also OptParseBuilder#separator and OptParseBuilder#footer
128
+ def separator(line, footer: true)
129
+ if footer
130
+ warn "separator with footer text is deprecated and will" +
131
+ " become positional in v2.0.0. Use footer(line) instead or" +
132
+ " separator(line, footer: false) for positional."
133
+ @footer_lines << line
134
+ else
135
+ @separator_lines << line
136
+ end
137
+ end
138
+
139
+ # Add to the footer text shown at the bottom of --help output.
140
+ # You may call this more than once; each call adds another line
141
+ # of text to the footer.
142
+ #
143
+ # This is the recommended way to add text at the bottom of help
144
+ # output in v1.1.0 and later.
145
+ #
146
+ # Any type of argument may have footer text.
147
+ #
148
+ # See also OptParseBuilder#footer
149
+ def footer(line)
150
+ @footer_lines << line
123
151
  end
124
152
 
125
153
  # Declare the operand to be an optional operand. An optional
@@ -155,9 +183,6 @@ module OptParseBuilder
155
183
  unless @banner_lines.empty?
156
184
  bundle << BannerArgument.new(@banner_lines)
157
185
  end
158
- unless @separator_lines.empty?
159
- bundle << SeparatorArgument.new(@separator_lines)
160
- end
161
186
  if !@on.empty?
162
187
  bundle << OptionArgument.new(@key, @default, @on, @handler)
163
188
  elsif @operand_class
@@ -171,6 +196,12 @@ module OptParseBuilder
171
196
  bundle << ConstantArgument.new(@key, @default)
172
197
  end
173
198
  end
199
+ unless @separator_lines.empty?
200
+ bundle << SeparatorArgument.new(@separator_lines)
201
+ end
202
+ unless @footer_lines.empty?
203
+ bundle << FooterArgument.new(@footer_lines)
204
+ end
174
205
  bundle.simplify
175
206
  end
176
207
 
@@ -0,0 +1,11 @@
1
+ module OptParseBuilder
2
+ class FooterArgument < Argument # :nodoc:
3
+
4
+ attr_reader :footer_lines
5
+
6
+ def initialize(footer_lines)
7
+ @footer_lines = footer_lines
8
+ end
9
+
10
+ end
11
+ end
@@ -151,14 +151,20 @@ module OptParseBuilder
151
151
  # Although it's called a "line," you can embed new-lines in it so
152
152
  # that it is actually more than one line.
153
153
  #
154
+ # The footer: parameter controls where the text appears:
155
+ # * footer: true (default in v1.x) - text appears at bottom
156
+ # (DEPRECATED: use footer method instead)
157
+ # * footer: false - text appears positionally between options
158
+ # (will be default in v2.0.0)
159
+ #
154
160
  # This example:
155
161
  #
156
162
  # arg_parser = OptParseBuilder.build_parser do |args|
157
- # args.separator "Here I explain more about my program"
158
- # args.separator <<~SEPARATOR
163
+ # args.footer "Here I explain more about my program"
164
+ # args.footer <<~FOOTER
159
165
  # For such a small program,
160
166
  # it has a lot of text at the end.
161
- # SEPARATOR
167
+ # FOOTER
162
168
  # end
163
169
  # arg_parser.parse!(["--help"])
164
170
  #
@@ -168,9 +174,42 @@ module OptParseBuilder
168
174
  # Here I explain more about my program
169
175
  # For such a small program,
170
176
  # it has a lot of text at the end.
171
- def separator(line)
177
+ def separator(line, footer: true)
172
178
  add do |arg|
173
- arg.separator(line)
179
+ arg.separator(line, footer: footer)
180
+ end
181
+ end
182
+
183
+ # Add a line to the footer. The footer is text that appears
184
+ # at the bottom of the help text.
185
+ #
186
+ # A new-line will automatically be added to the end of the line.
187
+ # Although it's called a "line," you can embed new-lines in it so
188
+ # that it is actually more than one line.
189
+ #
190
+ # This is the recommended way to add text at the bottom of help
191
+ # output in v1.1.0 and later.
192
+ #
193
+ # This example:
194
+ #
195
+ # arg_parser = OptParseBuilder.build_parser do |args|
196
+ # args.footer "Here I explain more about my program"
197
+ # args.footer <<~FOOTER
198
+ # For such a small program,
199
+ # it has a lot of text at the end.
200
+ # FOOTER
201
+ # end
202
+ # arg_parser.parse!(["--help"])
203
+ #
204
+ # Results in `--help` output like this:
205
+ #
206
+ # Usage: example [options] <path>
207
+ # Here I explain more about my program
208
+ # For such a small program,
209
+ # it has a lot of text at the end.
210
+ def footer(line)
211
+ add do |arg|
212
+ arg.footer(line)
174
213
  end
175
214
  end
176
215
 
@@ -313,12 +352,17 @@ module OptParseBuilder
313
352
  def optparse
314
353
  op = OptParse.new
315
354
  op.banner = banner_prefix + op.banner + banner_suffix
316
- @arguments.each { |arg| arg.apply_option(op) }
317
- @arguments.each do |argument|
318
- argument.separator_lines.each do |line|
355
+ @arguments.each do |arg|
356
+ arg.apply_option(op)
357
+ arg.separator_lines.each do |line|
319
358
  op.separator(line)
320
359
  end
321
360
  end
361
+ @arguments.each do |argument|
362
+ argument.footer_lines.each do |line|
363
+ op.on_tail(line)
364
+ end
365
+ end
322
366
  op
323
367
  end
324
368
 
@@ -11,7 +11,7 @@ module OptParseBuilder
11
11
  @parser = Parser.new
12
12
  end
13
13
 
14
- def_delegators :@parser, :add, :banner, :separator
14
+ def_delegators :@parser, :add, :banner, :separator, :footer
15
15
 
16
16
  end
17
17
  end
@@ -1,6 +1,6 @@
1
1
  module OptParseBuilder
2
2
 
3
3
  # Library version. Follows Semantic Versioning 2.0
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
 
6
6
  end
@@ -8,6 +8,7 @@ require_relative "opt_parse_builder/argument_values"
8
8
  require_relative "opt_parse_builder/banner_argument"
9
9
  require_relative "opt_parse_builder/constant_argument"
10
10
  require_relative "opt_parse_builder/errors"
11
+ require_relative "opt_parse_builder/footer_argument"
11
12
  require_relative "opt_parse_builder/formats_operand_name"
12
13
  require_relative "opt_parse_builder/has_value"
13
14
  require_relative "opt_parse_builder/null_argument"
@@ -53,7 +54,7 @@ require_relative "opt_parse_builder/stable_sort"
53
54
  # arg.on "--size=N", Integer
54
55
  # arg.on "Size in bytes (default _DEFAULT_)"
55
56
  # end
56
- # parser.separator "Explanatory text at the bottom"
57
+ # parser.footer "Explanatory text at the bottom"
57
58
  # end
58
59
  # arg_values = arg_parser.parse!
59
60
  # p arg_values.quiet # nil or true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opt_parse_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wayne Conrad
@@ -83,6 +83,7 @@ files:
83
83
  - lib/opt_parse_builder/banner_argument.rb
84
84
  - lib/opt_parse_builder/constant_argument.rb
85
85
  - lib/opt_parse_builder/errors.rb
86
+ - lib/opt_parse_builder/footer_argument.rb
86
87
  - lib/opt_parse_builder/formats_operand_name.rb
87
88
  - lib/opt_parse_builder/has_value.rb
88
89
  - lib/opt_parse_builder/null_argument.rb