toys 0.14.7 → 0.15.1

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: dff2ae40b96b0233329db81e892e66e4a32d3784d02a41e748ed27911a33b485
4
- data.tar.gz: 1a5fb082570d1811a17de821ed996c763b354db7e2bf6d2663d7f2f73fdd5769
3
+ metadata.gz: d18a73fddd4b4c4de686cadd776da8c6a70c425863382ce8ca33d4a68b0dd1ec
4
+ data.tar.gz: 5aca86d6e4a359c002b2a996ee6456ee4152bafcb7e981e315a0c26f338c49b8
5
5
  SHA512:
6
- metadata.gz: 4c46b28e9de47f61c4fb10a368b235c327e43979bac1b85e399c86709d3145ce478f1ce78d5dc1e493d77c02ea5d6149b52a5f71ecf070746279b5776ec7e09c
7
- data.tar.gz: ee9c59b7ccdc02db6ccdf55889a42d408714f4523c55a2f477a673551baf7d7de3c94c3ef12ef5cfa16fb5b2c75c0394f09e14e1387c0136afe6b716dccb253b
6
+ metadata.gz: 4d1160317e3f7005729afef9faefe364e96cfa44afe6aaad984ab0f00369e51ad3d40bd8643a13cbb711efa23cc5b86f03f94c63ad826ffae1b790293e051027
7
+ data.tar.gz: 0f913098f67b499d42376052ec24f1104d6085f388acd8dc579dbbe4e5b022a85300b6b7a7112a8e97b6e9fdd50533561fb8dd9764b41693d10440b7c17d9e36
data/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Release History
2
2
 
3
+ ### v0.15.1 / 2023-10-15
4
+
5
+ * FIXED: Clean up some internal requires, which may improve performance with built-in gems.
6
+
7
+ ### v0.15.0 / 2023-10-12
8
+
9
+ Toys 0.15.0 is a major release that adds arbitrary signal handling, cleans up some warts around entrypoint and method definition, and fixes a few long-standing issues.
10
+
11
+ Breaking changes:
12
+
13
+ * If a missing delegate or a delegation loop is detected, ToolDefinitionError is raised instead of RuntimeError.
14
+ * Passing a block to the to_run directive no longer defines the "run" method, but simply uses the block as the run entrypoint.
15
+ * The default algorithm for determining whether flags and arguments add methods now allows overriding of methods of Toys::Context and any other included modules, but prevents collisions with private methods defined in the tool. (It continues to prevent overriding of public methods of Object and BasicObject.)
16
+
17
+ New functionality:
18
+
19
+ * New DSL directive on_signal lets tools provide signal handlers.
20
+ * You can pass a symbol to the to_run directive to set the entrypoint to a method other than "run".
21
+ * Flags and arguments can be configured explicitly to add methods or not add methods, overriding the default behavior.
22
+ * The minitest template has a configuration argument that defines MT_COMPAT.
23
+
24
+ Fixes and documentation:
25
+
26
+ * The Bundler integration prevents Bundler from attempting to self-update to the version specified in a lockfile (which would often cause problems when Bundler is called from Toys).
27
+ * Tools generated by the minitest and rspec standard templates can now interact properly with stdin (e.g. so you can invoke pry temporarily from a test.)
28
+ * Some cleanup of varioius mixins to prevent issues if their methods ever get overridden.
29
+ * Various improvements and clarifications in the reference documentation and user guide.
30
+
3
31
  ### v0.14.7 / 2023-07-19
4
32
 
5
33
  * FIXED: Fixed an exception when passing a non-string to puts in the terminal mixin
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # License
2
2
 
3
- Copyright 2019-2022 Daniel Azuma and the Toys contributors
3
+ Copyright 2019-2023 Daniel Azuma and the Toys contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -249,7 +249,7 @@ you can often rewrite an entire Rakefile as a Toys file and get quite a bit of
249
249
  benefit in readability and maintainability. For an example, see the
250
250
  [Toys file for the Toys gem itself](https://github.com/dazuma/toys/blob/main/toys/.toys/.toys.rb).
251
251
  It contains Toys scripts that I use to develop, test, and release Toys itself.
252
- Yes, Toys is self-hosted. You'll notice most of this Toys file consists of
252
+ Yes, Toys is self-hosted. You'll notice much of this Toys file consists of
253
253
  template expansions. Toys provides templates for a lot of common build, test,
254
254
  and release tasks for Ruby projects.
255
255
 
@@ -276,6 +276,9 @@ separate files. Such directories are versatile, letting you organize your tool
276
276
  definitions, along with shared code, normal Ruby classes, tests, and even data
277
277
  files for use by tools.
278
278
 
279
+ You can find detailed usage information, including the entire DSL, in the
280
+ [class reference documentation](https://dazuma.github.io/toys/gems/toys/latest/Toys.html)
281
+
279
282
  Unlike most command line frameworks, Toys is *not primarily* designed to help
280
283
  you build and ship a custom command line executable written in Ruby. However,
281
284
  you *can* use it in that way with the "toys-core" API, available as a separate
@@ -323,7 +326,7 @@ because it has a few known bugs that affect Toys.
323
326
 
324
327
  ## License
325
328
 
326
- Copyright 2019-2022 Daniel Azuma and the Toys contributors
329
+ Copyright 2019-2023 Daniel Azuma and the Toys contributors
327
330
 
328
331
  Permission is hereby granted, free of charge, to any person obtaining a copy
329
332
  of this software and associated documentation files (the "Software"), to deal
@@ -23,36 +23,18 @@ flag :minitest_focus, "--minitest-focus[=VERSION]",
23
23
  desc: "Make minitest-focus available during the run"
24
24
  flag :minitest_rg, "--minitest-rg[=VERSION]",
25
25
  desc: "Make minitest-rg available during the run"
26
+ flag :minitest_compat, "--[no-]minitest-compat",
27
+ desc: "Set MT_COMPAT to retain compatibility with certain old plugins"
26
28
 
27
29
  include :exec
28
30
  include :gems
29
31
  include :terminal
30
32
 
31
33
  def run
34
+ env = ruby_env
35
+ ENV["MT_COMPAT"] = env["MT_COMPAT"] if env.key?("MT_COMPAT")
32
36
  load_minitest_gems
33
- test_files = find_test_files
34
- result = exec_ruby(ruby_args, in: :controller, log_cmd: "Starting minitest...") do |controller|
35
- controller.in.puts("gem 'minitest', '= #{::Minitest::VERSION}'")
36
- controller.in.puts("require 'minitest/autorun'")
37
- if minitest_focus
38
- controller.in.puts("gem 'minitest-focus', '= #{::Minitest::Test::Focus::VERSION}'")
39
- controller.in.puts("require 'minitest/focus'")
40
- end
41
- if minitest_rg
42
- controller.in.puts("gem 'minitest-rg', '= #{::MiniTest::RG::VERSION}'")
43
- controller.in.puts("require 'minitest/rg'")
44
- end
45
- controller.in.puts("require 'toys'")
46
- controller.in.puts("require 'toys/testing'")
47
- if directory
48
- dir_str = ::File.absolute_path(directory).inspect
49
- controller.in.puts("Toys::Testing.toys_custom_paths(#{dir_str})")
50
- controller.in.puts("Toys::Testing.toys_include_builtins(false)")
51
- end
52
- test_files.each do |file|
53
- controller.in.puts("load '#{file}'")
54
- end
55
- end
37
+ result = exec_ruby(ruby_args, log_cmd: "Starting minitest...", env: env)
56
38
  if result.error?
57
39
  logger.error("Minitest failed!")
58
40
  exit(result.exit_code)
@@ -74,6 +56,54 @@ def load_minitest_gems
74
56
  end
75
57
  end
76
58
 
59
+ def ruby_env
60
+ case minitest_compat
61
+ when true
62
+ { "MT_COMPAT" => "true" }
63
+ when false
64
+ { "MT_COMPAT" => nil }
65
+ else
66
+ {}
67
+ end
68
+ end
69
+
70
+ def ruby_args
71
+ args = []
72
+ args << "-w" if warnings
73
+ args << "-I#{::Toys::CORE_LIB_PATH}#{::File::PATH_SEPARATOR}#{::Toys::LIB_PATH}"
74
+ args << "-e" << ruby_code.join("\n")
75
+ args << "--"
76
+ args << "--seed" << seed if seed
77
+ args << "--verbose" if verbosity.positive?
78
+ args << "--name" << name if name
79
+ args << "--exclude" << exclude if exclude
80
+ args
81
+ end
82
+
83
+ def ruby_code
84
+ code = []
85
+ code << "gem 'minitest', '= #{::Minitest::VERSION}'"
86
+ code << "require 'minitest/autorun'"
87
+ if minitest_focus
88
+ code << "gem 'minitest-focus', '= #{::Minitest::Test::Focus::VERSION}'"
89
+ code << "require 'minitest/focus'"
90
+ end
91
+ if minitest_rg
92
+ code << "gem 'minitest-rg', '= #{::MiniTest::RG::VERSION}'"
93
+ code << "require 'minitest/rg'"
94
+ end
95
+ code << "require 'toys'"
96
+ code << "require 'toys/testing'"
97
+ if directory
98
+ code << "Toys::Testing.toys_custom_paths(#{::File.absolute_path(directory).inspect})"
99
+ code << "Toys::Testing.toys_include_builtins(false)"
100
+ end
101
+ find_test_files.each do |file|
102
+ code << "load '#{file}'"
103
+ end
104
+ code
105
+ end
106
+
77
107
  def find_test_files
78
108
  glob = ".test/**/test_*.rb"
79
109
  glob = "**/#{glob}" if recursive
@@ -116,15 +146,3 @@ def base_dir
116
146
  dir = parent
117
147
  end
118
148
  end
119
-
120
- def ruby_args
121
- args = []
122
- args << "-w" if warnings
123
- args << "-I#{::Toys::CORE_LIB_PATH}#{::File::PATH_SEPARATOR}#{::Toys::LIB_PATH}"
124
- args << "-"
125
- args << "--seed" << seed if seed
126
- args << "--verbose" if verbosity.positive?
127
- args << "--name" << name if name
128
- args << "--exclude" << exclude if exclude
129
- args
130
- end
@@ -68,7 +68,7 @@ module Toys
68
68
  # * `preload_dir_name`: Name of preload directories in tool directories
69
69
  # * `data_dir_name`: Name of data directories in tool directories
70
70
  #
71
- # @param logger [Logger] A global logger to use for all tools. This may be
71
+ # @param logger [Logger] A global logger to use for all tools. This can be
72
72
  # set if the CLI will call at most one tool at a time. However, it will
73
73
  # behave incorrectly if CLI might run multiple tools at the same time
74
74
  # with different verbosity settings (since the logger cannot have
@@ -76,19 +76,21 @@ module Toys
76
76
  # global logger, but use the `logger_factory` parameter instead.
77
77
  # @param logger_factory [Proc] A proc that takes a {Toys::ToolDefinition}
78
78
  # as an argument, and returns a `Logger` to use when running that tool.
79
- # Optional. If not provided (and no global logger is set), CLI will use
80
- # a default factory that writes generates loggers writing formatted
81
- # output to `STDERR`, as defined by {Toys::CLI.default_logger_factory}.
79
+ # Optional. If not provided (and no global logger is set),
80
+ # {Toys::CLI.default_logger_factory} is called to get a basic default.
82
81
  # @param base_level [Integer] The logger level that should correspond
83
82
  # to zero verbosity.
84
83
  # Optional. If not provided, defaults to the current level of the
85
84
  # logger (which is often `Logger::WARN`).
86
- # @param error_handler [Proc,nil] A proc that is called when an error is
87
- # caught. The proc should take a {Toys::ContextualError} argument and
88
- # report the error. It should return an exit code (normally nonzero).
89
- # Optional. If not provided, defaults to an instance of
90
- # {Toys::CLI::DefaultErrorHandler}, which displays an error message to
91
- # `STDERR`.
85
+ # @param error_handler [Proc,nil] A proc that is called when an unhandled
86
+ # exception (a normal exception subclassing `StandardError`, an error
87
+ # loading a toys config file subclassing `SyntaxError`, or an unhandled
88
+ # signal subclassing `SignalException`) is detected. The proc should
89
+ # take a {Toys::ContextualError}, whose cause is the unhandled
90
+ # exception, as the sole argument, and report the error. It should
91
+ # return an exit code (normally nonzero) appropriate to the error.
92
+ # Optional. If not provided, {Toys::CLI.default_error_handler} is
93
+ # called to get a basic default handler.
92
94
  # @param executable_name [String] The executable name displayed in help
93
95
  # text. Optional. Defaults to the ruby program name.
94
96
  #
@@ -97,9 +99,8 @@ module Toys
97
99
  # characters are period, colon, and slash.
98
100
  # @param completion [Toys::Completion::Base] A specifier for shell tab
99
101
  # completion for the CLI as a whole.
100
- # Optional. If not provided, defaults to an instance of
101
- # {Toys::CLI::DefaultCompletion}, which delegates completion to the
102
- # relevant tool.
102
+ # Optional. If not provided, {Toys::CLI.default_completion} is called
103
+ # to get a default completion that delegates to the tool.
103
104
  #
104
105
  # @param middleware_stack [Array<Toys::Middleware::Spec>] An array of
105
106
  # middleware that will be used by default for all tools.
@@ -382,53 +383,6 @@ module Toys
382
383
  # Source available in the toys-core gem
383
384
  end
384
385
 
385
- ##
386
- # **_Defined in the toys-core gem_**
387
- #
388
- # A basic error handler that prints out captured errors to a stream or
389
- # a logger.
390
- #
391
- class DefaultErrorHandler
392
- ##
393
- # Create an error handler.
394
- #
395
- # @param output [IO,nil] Where to write errors. Default is `$stderr`.
396
- #
397
- def initialize(output: $stderr)
398
- # Source available in the toys-core gem
399
- end
400
-
401
- ##
402
- # The error handler routine. Prints out the error message and backtrace,
403
- # and returns the correct result code.
404
- #
405
- # @param error [Exception] The error that occurred.
406
- # @return [Integer] The result code for the execution.
407
- #
408
- def call(error)
409
- # Source available in the toys-core gem
410
- end
411
- end
412
-
413
- ##
414
- # **_Defined in the toys-core gem_**
415
- #
416
- # A Completion that implements the default algorithm for a CLI. This
417
- # algorithm simply determines the tool and uses its completion.
418
- #
419
- class DefaultCompletion < Completion::Base
420
- ##
421
- # Returns candidates for the current completion.
422
- #
423
- # @param context [Toys::Completion::Context] the current completion
424
- # context including the string fragment.
425
- # @return [Array<Toys::Completion::Candidate>] an array of candidates
426
- #
427
- def call(context)
428
- # Source available in the toys-core gem
429
- end
430
- end
431
-
432
386
  class << self
433
387
  ##
434
388
  # Returns a default set of middleware that may be used as a starting
@@ -478,16 +432,35 @@ module Toys
478
432
  end
479
433
 
480
434
  ##
481
- # Returns a logger factory that generates loggers that write to stderr.
482
- # All loggers generated by this factory share a single
483
- # {Toys::Utils::Terminal}, so log entries may interleave but will not
484
- # interrupt one another.
435
+ # Returns a bare-bones error handler that takes simply reraises the
436
+ # error. If the original error (the cause of the {Toys::ContextualError})
437
+ # was a `SignalException` (or a subclass such as `Interrupted`), that
438
+ # `SignalException` itself is reraised so that the Ruby VM has a chance
439
+ # to handle it. Otherwise, for any other error, the
440
+ # {Toys::ContextualError} is reraised.
441
+ #
442
+ # @return [Proc]
443
+ #
444
+ def default_error_handler
445
+ # Source available in the toys-core gem
446
+ end
447
+
448
+ ##
449
+ # Returns a default logger factory that generates simple loggers that
450
+ # write to STDERR.
485
451
  #
486
452
  # @return [Proc]
487
453
  #
488
454
  def default_logger_factory
489
455
  # Source available in the toys-core gem
490
456
  end
457
+
458
+ ##
459
+ # Returns a default Completion that simply uses the tool's completion.
460
+ #
461
+ def default_completion
462
+ # Source available in the toys-core gem
463
+ end
491
464
  end
492
465
  end
493
466
  end
@@ -141,22 +141,30 @@ module Toys
141
141
  #
142
142
  # This is a convenience getter for {Toys::Context::Key::ARGS}.
143
143
  #
144
+ # If the `args` method is overridden by the tool, you can still access it
145
+ # using the name `__args`.
146
+ #
144
147
  # @return [Array<String>]
145
148
  #
146
149
  def args
147
150
  # Source available in the toys-core gem
148
151
  end
152
+ alias __args args
149
153
 
150
154
  ##
151
155
  # The currently running CLI.
152
156
  #
153
157
  # This is a convenience getter for {Toys::Context::Key::CLI}.
154
158
  #
159
+ # If the `cli` method is overridden by the tool, you can still access it
160
+ # using the name `__cli`.
161
+ #
155
162
  # @return [Toys::CLI]
156
163
  #
157
164
  def cli
158
165
  # Source available in the toys-core gem
159
166
  end
167
+ alias __cli cli
160
168
 
161
169
  ##
162
170
  # Return the context directory for this tool. Generally, this defaults
@@ -166,71 +174,98 @@ module Toys
166
174
  #
167
175
  # This is a convenience getter for {Toys::Context::Key::CONTEXT_DIRECTORY}.
168
176
  #
177
+ # If the `context_directory` method is overridden by the tool, you can
178
+ # still access it using the name `__context_directory`.
179
+ #
169
180
  # @return [String] Context directory path
170
181
  # @return [nil] if there is no context.
171
182
  #
172
183
  def context_directory
173
184
  # Source available in the toys-core gem
174
185
  end
186
+ alias __context_directory context_directory
175
187
 
176
188
  ##
177
189
  # The logger for this execution.
178
190
  #
179
191
  # This is a convenience getter for {Toys::Context::Key::LOGGER}.
180
192
  #
193
+ # If the `logger` method is overridden by the tool, you can still access it
194
+ # using the name `__logger`.
195
+ #
181
196
  # @return [Logger]
182
197
  #
183
198
  def logger
184
199
  # Source available in the toys-core gem
185
200
  end
201
+ alias __logger logger
186
202
 
187
203
  ##
188
204
  # The full name of the tool being executed, as an array of strings.
189
205
  #
190
206
  # This is a convenience getter for {Toys::Context::Key::TOOL_NAME}.
191
207
  #
208
+ # If the `tool_name` method is overridden by the tool, you can still access
209
+ # it using the name `__tool_name`.
210
+ #
192
211
  # @return [Array<String>]
193
212
  #
194
213
  def tool_name
195
214
  # Source available in the toys-core gem
196
215
  end
216
+ alias __tool_name tool_name
197
217
 
198
218
  ##
199
219
  # The source of the tool being executed.
200
220
  #
201
221
  # This is a convenience getter for {Toys::Context::Key::TOOL_SOURCE}.
202
222
  #
223
+ # If the `tool_source` method is overridden by the tool, you can still
224
+ # access it using the name `__tool_source`.
225
+ #
203
226
  # @return [Toys::SourceInfo]
204
227
  #
205
228
  def tool_source
206
229
  # Source available in the toys-core gem
207
230
  end
231
+ alias __tool_source tool_source
208
232
 
209
233
  ##
210
234
  # The (possibly empty) array of errors detected during argument parsing.
211
235
  #
212
236
  # This is a convenience getter for {Toys::Context::Key::USAGE_ERRORS}.
213
237
  #
238
+ # If the `usage_errors` method is overridden by the tool, you can still
239
+ # access it using the name `__usage_errors`.
240
+ #
214
241
  # @return [Array<Toys::ArgParser::UsageError>]
215
242
  #
216
243
  def usage_errors
217
244
  # Source available in the toys-core gem
218
245
  end
246
+ alias __usage_errors usage_errors
219
247
 
220
248
  ##
221
249
  # The current verbosity setting as an integer.
222
250
  #
223
251
  # This is a convenience getter for {Toys::Context::Key::VERBOSITY}.
224
252
  #
253
+ # If the `verbosity` method is overridden by the tool, you can still access
254
+ # it using the name `__verbosity`.
255
+ #
225
256
  # @return [Integer]
226
257
  #
227
258
  def verbosity
228
259
  # Source available in the toys-core gem
229
260
  end
261
+ alias __verbosity verbosity
230
262
 
231
263
  ##
232
264
  # Fetch an option or other piece of data by key.
233
265
  #
266
+ # If the `get` method is overridden by the tool, you can still access it
267
+ # using the name `__get` or the `[]` operator.
268
+ #
234
269
  # @param key [Symbol]
235
270
  # @return [Object]
236
271
  #
@@ -253,6 +288,9 @@ module Toys
253
288
  ##
254
289
  # Set one or more options or other context data by key.
255
290
  #
291
+ # If the `set` method is overridden by the tool, you can still access it
292
+ # using the name `__set`.
293
+ #
256
294
  # @return [self]
257
295
  #
258
296
  # @overload set(key, value)
@@ -269,6 +307,7 @@ module Toys
269
307
  def set(key, value = nil)
270
308
  # Source available in the toys-core gem
271
309
  end
310
+ alias __set set
272
311
 
273
312
  ##
274
313
  # The subset of the context that uses string or symbol keys. By convention,
@@ -276,15 +315,22 @@ module Toys
276
315
  # include well-known context values such as verbosity or private context
277
316
  # values used by middleware or mixins.
278
317
  #
318
+ # If the `options` method is overridden by the tool, you can still access
319
+ # it using the name `__options`.
320
+ #
279
321
  # @return [Hash]
280
322
  #
281
323
  def options
282
324
  # Source available in the toys-core gem
283
325
  end
326
+ alias __options options
284
327
 
285
328
  ##
286
329
  # Find the given data file or directory in this tool's search path.
287
330
  #
331
+ # If the `find_data` method is overridden by the tool, you can still access
332
+ # it using the name `__find_data`.
333
+ #
288
334
  # @param path [String] The path to find
289
335
  # @param type [nil,:file,:directory] Type of file system object to find,
290
336
  # or nil to return any type.
@@ -295,10 +341,14 @@ module Toys
295
341
  def find_data(path, type: nil)
296
342
  # Source available in the toys-core gem
297
343
  end
344
+ alias __find_data find_data
298
345
 
299
346
  ##
300
347
  # Exit immediately with the given status code.
301
348
  #
349
+ # If the `exit` method is overridden by the tool, you can still access it
350
+ # using the name `__exit` or by calling {Context.exit}.
351
+ #
302
352
  # @param code [Integer] The status code, which should be 0 for no error,
303
353
  # or nonzero for an error condition. Default is 0.
304
354
  # @return [void]
@@ -306,6 +356,7 @@ module Toys
306
356
  def exit(code = 0)
307
357
  # Source available in the toys-core gem
308
358
  end
359
+ alias __exit exit
309
360
 
310
361
  ##
311
362
  # Exit immediately with the given status code. This class method can be
@@ -9,6 +9,6 @@ module Toys
9
9
  # Current version of Toys core.
10
10
  # @return [String]
11
11
  #
12
- VERSION = "0.14.7"
12
+ VERSION = "0.15.1"
13
13
  end
14
14
  end
@@ -117,7 +117,14 @@ module Toys
117
117
  # should be set. You may pass the handler as a Proc (or an object
118
118
  # responding to the `call` method) or you may pass a block.
119
119
  #
120
- # @param handler [Proc]
120
+ # You can also pass one of the special values `:set` or `:push` as the
121
+ # handler. The `:set` handler replaces the previous value (equivalent to
122
+ # `-> (val, _prev) { val }`.) The `:push` handler expects the previous
123
+ # value to be an array and pushes the given value onto it; it should be
124
+ # combined with setting the default value to `[]` and is intended for
125
+ # "multi-valued" flags.
126
+ #
127
+ # @param handler [Proc,:set,:push]
121
128
  # @param block [Proc]
122
129
  # @return [self]
123
130
  #
@@ -256,6 +263,22 @@ module Toys
256
263
  def display_name(display_name)
257
264
  # Source available in the toys-core gem
258
265
  end
266
+
267
+ ##
268
+ # Specify whether to add a method for this flag.
269
+ #
270
+ # Recognized values are true to force creation of a method, false to
271
+ # disable method creation, and nil for the default behavior. The default
272
+ # checks the name and adds a method if the name is a symbol representing
273
+ # a legal method name that starts with a letter and does not override any
274
+ # public method in the Ruby Object class or collide with any method
275
+ # directly defined in the tool class.
276
+ #
277
+ # @param value [true,false,nil]
278
+ #
279
+ def add_method(value)
280
+ # Source available in the toys-core gem
281
+ end
259
282
  end
260
283
  end
261
284
  end
@@ -181,13 +181,21 @@ module Toys
181
181
  # arguments.) Defaults to the empty array.
182
182
  # @param display_name [String] A display name for this flag, used in help
183
183
  # text and error messages.
184
+ # @param add_method [true,false,nil] Whether to add a method for this
185
+ # flag. If omitted or set to nil, uses the default behavior, which
186
+ # adds the method if the key is a symbol representing a legal method
187
+ # name that starts with a letter and does not override any public
188
+ # method in the Ruby Object class or collide with any method directly
189
+ # defined in the tool class.
184
190
  # @param block [Proc] Configures the flag. See {Toys::DSL::Flag} for the
185
191
  # directives that can be called in this block.
186
192
  # @return [self]
187
193
  #
188
194
  def flag(key, *flags,
189
- accept: nil, default: nil, handler: nil, complete_flags: nil, complete_values: nil,
190
- report_collisions: true, desc: nil, long_desc: nil, display_name: nil,
195
+ accept: nil, default: nil, handler: nil,
196
+ complete_flags: nil, complete_values: nil,
197
+ report_collisions: true, desc: nil, long_desc: nil,
198
+ display_name: nil, add_method: nil,
191
199
  &block)
192
200
  # Source available in the toys-core gem
193
201
  end
@@ -134,6 +134,22 @@ module Toys
134
134
  def long_desc(*long_desc)
135
135
  # Source available in the toys-core gem
136
136
  end
137
+
138
+ ##
139
+ # Specify whether to add a method for this argument.
140
+ #
141
+ # Recognized values are true to force creation of a method, false to
142
+ # disable method creation, and nil for the default behavior. The default
143
+ # checks the name and adds a method if the name is a symbol representing
144
+ # a legal method name that starts with a letter and does not override any
145
+ # public method in the Ruby Object class or collide with any method
146
+ # directly defined in the tool class.
147
+ #
148
+ # @param value [true,false,nil]
149
+ #
150
+ def add_method(value)
151
+ # Source available in the toys-core gem
152
+ end
137
153
  end
138
154
  end
139
155
  end