toys 0.17.1 → 0.17.2

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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +3 -3
  4. data/core-docs/toys/acceptor.rb +474 -0
  5. data/core-docs/toys/arg_parser.rb +397 -0
  6. data/core-docs/toys/cli.rb +466 -0
  7. data/core-docs/toys/compat.rb +2 -0
  8. data/core-docs/toys/completion.rb +340 -0
  9. data/core-docs/toys/context.rb +386 -0
  10. data/core-docs/toys/core.rb +14 -0
  11. data/core-docs/toys/dsl/base.rb +56 -0
  12. data/core-docs/toys/dsl/flag.rb +287 -0
  13. data/core-docs/toys/dsl/flag_group.rb +270 -0
  14. data/core-docs/toys/dsl/internal.rb +4 -0
  15. data/core-docs/toys/dsl/positional_arg.rb +155 -0
  16. data/core-docs/toys/dsl/tool.rb +1663 -0
  17. data/core-docs/toys/errors.rb +126 -0
  18. data/core-docs/toys/flag.rb +563 -0
  19. data/core-docs/toys/flag_group.rb +186 -0
  20. data/core-docs/toys/input_file.rb +17 -0
  21. data/core-docs/toys/loader.rb +411 -0
  22. data/core-docs/toys/middleware.rb +336 -0
  23. data/core-docs/toys/mixin.rb +142 -0
  24. data/core-docs/toys/module_lookup.rb +75 -0
  25. data/core-docs/toys/positional_arg.rb +145 -0
  26. data/core-docs/toys/settings.rb +524 -0
  27. data/core-docs/toys/source_info.rb +321 -0
  28. data/core-docs/toys/standard_middleware/add_verbosity_flags.rb +49 -0
  29. data/core-docs/toys/standard_middleware/apply_config.rb +24 -0
  30. data/core-docs/toys/standard_middleware/handle_usage_errors.rb +33 -0
  31. data/core-docs/toys/standard_middleware/set_default_descriptions.rb +222 -0
  32. data/core-docs/toys/standard_middleware/show_help.rb +190 -0
  33. data/core-docs/toys/standard_middleware/show_root_version.rb +45 -0
  34. data/core-docs/toys/standard_mixins/bundler.rb +98 -0
  35. data/core-docs/toys/standard_mixins/exec.rb +711 -0
  36. data/core-docs/toys/standard_mixins/fileutils.rb +18 -0
  37. data/core-docs/toys/standard_mixins/gems.rb +74 -0
  38. data/core-docs/toys/standard_mixins/git_cache.rb +41 -0
  39. data/core-docs/toys/standard_mixins/highline.rb +133 -0
  40. data/core-docs/toys/standard_mixins/pager.rb +50 -0
  41. data/core-docs/toys/standard_mixins/terminal.rb +135 -0
  42. data/core-docs/toys/standard_mixins/xdg.rb +49 -0
  43. data/core-docs/toys/template.rb +112 -0
  44. data/core-docs/toys/tool_definition.rb +1080 -0
  45. data/core-docs/toys/utils/completion_engine.rb +49 -0
  46. data/core-docs/toys/utils/exec.rb +776 -0
  47. data/core-docs/toys/utils/gems.rb +185 -0
  48. data/core-docs/toys/utils/git_cache.rb +368 -0
  49. data/core-docs/toys/utils/help_text.rb +134 -0
  50. data/core-docs/toys/utils/pager.rb +118 -0
  51. data/core-docs/toys/utils/standard_ui.rb +184 -0
  52. data/core-docs/toys/utils/terminal.rb +310 -0
  53. data/core-docs/toys/utils/xdg.rb +253 -0
  54. data/core-docs/toys/wrappable_string.rb +132 -0
  55. data/core-docs/toys-core.rb +111 -0
  56. data/lib/toys/version.rb +1 -1
  57. metadata +57 -5
@@ -0,0 +1,14 @@
1
+ module Toys
2
+ ##
3
+ # **_Defined in the toys-core gem_**
4
+ #
5
+ # The core Toys classes.
6
+ #
7
+ module Core
8
+ ##
9
+ # Current version of Toys core.
10
+ # @return [String]
11
+ #
12
+ VERSION = "0.17.2"
13
+ end
14
+ end
@@ -0,0 +1,56 @@
1
+ ##
2
+ # Create a base class for defining a tool with a given name.
3
+ #
4
+ # This method returns a base class for defining a tool with a given name.
5
+ # This is useful if the naming behavior of {Toys::Tool} is not adequate for
6
+ # your tool.
7
+ #
8
+ # ### Example
9
+ #
10
+ # class FooBar < Toys.Tool("Foo_Bar")
11
+ # desc "This is a tool called Foo_Bar"
12
+ #
13
+ # def run
14
+ # puts "Foo_Bar called"
15
+ # end
16
+ # end
17
+ #
18
+ # @param name [String] Name of the tool. Defaults to a name inferred from the
19
+ # class name. (See {Toys::Tool}.)
20
+ # @param base [Class] Use this tool class as the base class, and inherit helper
21
+ # methods from it.
22
+ # @param args [String,Class] Any string-valued positional argument is
23
+ # interpreted as the name. Any class-valued positional argument is
24
+ # interpreted as the base class.
25
+ #
26
+ def Toys.Tool(*args, name: nil, base: nil)
27
+ # Source available in the toys-core gem
28
+ end
29
+
30
+ module Toys
31
+ ##
32
+ # **_Defined in the toys-core gem_**
33
+ #
34
+ # Base class for defining tools
35
+ #
36
+ # This base class provides an alternative to the {Toys::DSL::Tool#tool}
37
+ # directive for defining tools in the Toys DSL. Creating a subclass of
38
+ # `Toys::Tool` will create a tool whose name is the "kebab-case" of the class
39
+ # name. Subclasses can be created only in the context of a tool configuration
40
+ # DSL. Furthermore, a class-defined tool can be created only at the top level
41
+ # of a configuration file, or within another class-defined tool. It cannot
42
+ # be a subtool of a tool block.
43
+ #
44
+ # ### Example
45
+ #
46
+ # class FooBar < Toys::Tool
47
+ # desc "This is a tool called foo-bar"
48
+ #
49
+ # def run
50
+ # puts "foo-bar called"
51
+ # end
52
+ # end
53
+ #
54
+ class Tool < Context
55
+ end
56
+ end
@@ -0,0 +1,287 @@
1
+ module Toys
2
+ module DSL
3
+ ##
4
+ # **_Defined in the toys-core gem_**
5
+ #
6
+ # DSL for a flag definition block. Lets you set flag attributes in a block
7
+ # instead of a long series of keyword arguments.
8
+ #
9
+ # These directives are available inside a block passed to
10
+ # {Toys::DSL::Tool#flag}.
11
+ #
12
+ # ### Example
13
+ #
14
+ # tool "mytool" do
15
+ # flag :value do
16
+ # # The directives in here are defined by this class
17
+ # flags "--value=VAL"
18
+ # accept Integer
19
+ # desc "An integer value"
20
+ # end
21
+ # # ...
22
+ # end
23
+ #
24
+ class Flag
25
+ ##
26
+ # Add flags in OptionParser format. This may be called multiple times,
27
+ # and the results are cumulative.
28
+ #
29
+ # Following are examples of valid syntax.
30
+ #
31
+ # * `-a` : A short boolean switch. When this appears as an argument,
32
+ # the value is set to `true`.
33
+ # * `--abc` : A long boolean switch. When this appears as an argument,
34
+ # the value is set to `true`.
35
+ # * `-aVAL` or `-a VAL` : A short flag that takes a required value.
36
+ # These two forms are treated identically. If this argument appears
37
+ # with a value attached (e.g. `-afoo`), the attached string (e.g.
38
+ # `"foo"`) is taken as the value. Otherwise, the following argument
39
+ # is taken as the value (e.g. for `-a foo`, the value is set to
40
+ # `"foo"`.) The following argument is treated as the value even if it
41
+ # looks like a flag (e.g. `-a -a` causes the string `"-a"` to be
42
+ # taken as the value.)
43
+ # * `-a[VAL]` : A short flag that takes an optional value. If this
44
+ # argument appears with a value attached (e.g. `-afoo`), the attached
45
+ # string (e.g. `"foo"`) is taken as the value. Otherwise, the value
46
+ # is set to `true`. The following argument is never interpreted as
47
+ # the value. (Compare with `-a [VAL]`.)
48
+ # * `-a [VAL]` : A short flag that takes an optional value. If this
49
+ # argument appears with a value attached (e.g. `-afoo`), the attached
50
+ # string (e.g. `"foo"`) is taken as the value. Otherwise, if the
51
+ # following argument does not look like a flag (i.e. it does not
52
+ # begin with a hyphen), it is taken as the value. (e.g. `-a foo`
53
+ # causes the string `"foo"` to be taken as the value.). If there is
54
+ # no following argument, or the following argument looks like a flag,
55
+ # the value is set to `true`. (Compare with `-a[VAL]`.)
56
+ # * `--abc=VAL` or `--abc VAL` : A long flag that takes a required
57
+ # value. These two forms are treated identically. If this argument
58
+ # appears with a value attached (e.g. `--abc=foo`), the attached
59
+ # string (e.g. `"foo"`) is taken as the value. Otherwise, the
60
+ # following argument is taken as the value (e.g. for `--abc foo`, the
61
+ # value is set to `"foo"`.) The following argument is treated as the
62
+ # value even if it looks like a flag (e.g. `--abc --def` causes the
63
+ # string `"--def"` to be taken as the value.)
64
+ # * `--abc[=VAL]` : A long flag that takes an optional value. If this
65
+ # argument appears with a value attached (e.g. `--abc=foo`), the
66
+ # attached string (e.g. `"foo"`) is taken as the value. Otherwise,
67
+ # the value is set to `true`. The following argument is never
68
+ # interpreted as the value. (Compare with `--abc [VAL]`.)
69
+ # * `--abc [VAL]` : A long flag that takes an optional value. If this
70
+ # argument appears with a value attached (e.g. `--abc=foo`), the
71
+ # attached string (e.g. `"foo"`) is taken as the value. Otherwise, if
72
+ # the following argument does not look like a flag (i.e. it does not
73
+ # begin with a hyphen), it is taken as the value. (e.g. `--abc foo`
74
+ # causes the string `"foo"` to be taken as the value.). If there is
75
+ # no following argument, or the following argument looks like a flag,
76
+ # the value is set to `true`. (Compare with `--abc=[VAL]`.)
77
+ # * `--[no-]abc` : A long boolean switch that can be turned either on
78
+ # or off. This effectively creates two flags, `--abc` which sets the
79
+ # value to `true`, and `--no-abc` which sets the falue to `false`.
80
+ #
81
+ # @param flags [String...]
82
+ # @return [self]
83
+ #
84
+ def flags(*flags)
85
+ # Source available in the toys-core gem
86
+ end
87
+
88
+ ##
89
+ # Set the acceptor for this flag's values.
90
+ # You can pass either the string name of an acceptor defined in this tool
91
+ # or any of its ancestors, or any other specification recognized by
92
+ # {Toys::Acceptor.create}.
93
+ #
94
+ # @param spec [Object]
95
+ # @param options [Hash]
96
+ # @param block [Proc]
97
+ # @return [self]
98
+ #
99
+ def accept(spec = nil, **options, &block)
100
+ # Source available in the toys-core gem
101
+ end
102
+
103
+ ##
104
+ # Set the default value.
105
+ #
106
+ # @param default [Object]
107
+ # @return [self]
108
+ #
109
+ def default(default)
110
+ # Source available in the toys-core gem
111
+ end
112
+
113
+ ##
114
+ # Set the optional handler that customizes how a value is set or updated
115
+ # when the flag is parsed.
116
+ #
117
+ # A handler is a proc that takes up to three arguments: the given value,
118
+ # the previous value, and a hash containing all the data collected so far
119
+ # during argument parsing. It must return the new value for the flag. You
120
+ # You may pass the handler as a Proc (or an object responding to the
121
+ # `call` method) or you may provide a block.
122
+ #
123
+ # You may also specify a predefined named handler. The `:set` handler
124
+ # (the default) replaces the previous value (effectively
125
+ # `-> (val) { val }`). The `:push` handler expects the previous value to
126
+ # be an array and pushes the given value onto it; it should be combined
127
+ # with setting the default value to `[]` and is intended for
128
+ # "multi-valued" flags.
129
+ #
130
+ # @param handler [Proc,:set,:push]
131
+ # @param block [Proc]
132
+ # @return [self]
133
+ #
134
+ def handler(handler = nil, &block)
135
+ # Source available in the toys-core gem
136
+ end
137
+
138
+ ##
139
+ # Set the shell completion strategy for flag names.
140
+ # You can pass one of the following:
141
+ #
142
+ # * The string name of a completion defined in this tool or any of its
143
+ # ancestors.
144
+ # * A hash of options to pass to the constructor of
145
+ # {Toys::Flag::DefaultCompletion}.
146
+ # * `nil` or `:default` to select the standard completion strategy
147
+ # (which is {Toys::Flag::DefaultCompletion} with no extra options).
148
+ # * Any other specification recognized by {Toys::Completion.create}.
149
+ #
150
+ # @param spec [Object]
151
+ # @param options [Hash]
152
+ # @param block [Proc]
153
+ # @return [self]
154
+ #
155
+ def complete_flags(spec = nil, **options, &block)
156
+ # Source available in the toys-core gem
157
+ end
158
+
159
+ ##
160
+ # Set the shell completion strategy for flag values.
161
+ # You can pass either the string name of a completion defined in this
162
+ # tool or any of its ancestors, or any other specification recognized by
163
+ # {Toys::Completion.create}.
164
+ #
165
+ # @param spec [Object]
166
+ # @param options [Hash]
167
+ # @param block [Proc]
168
+ # @return [self]
169
+ #
170
+ def complete_values(spec = nil, **options, &block)
171
+ # Source available in the toys-core gem
172
+ end
173
+
174
+ ##
175
+ # Set whether to raise an exception if a flag is requested that is
176
+ # already in use or marked as disabled.
177
+ #
178
+ # @param setting [Boolean]
179
+ # @return [self]
180
+ #
181
+ def report_collisions(setting)
182
+ # Source available in the toys-core gem
183
+ end
184
+
185
+ ##
186
+ # Set the short description for the current flag. The short description
187
+ # is displayed with the flag in online help.
188
+ #
189
+ # The description is a {Toys::WrappableString}, which may be word-wrapped
190
+ # when displayed in a help screen. You may pass a {Toys::WrappableString}
191
+ # directly to this method, or you may pass any input that can be used to
192
+ # construct a wrappable string:
193
+ #
194
+ # * If you pass a String, its whitespace will be compacted (i.e. tabs,
195
+ # newlines, and multiple consecutive whitespace will be turned into a
196
+ # single space), and it will be word-wrapped on whitespace.
197
+ # * If you pass an Array of Strings, each string will be considered a
198
+ # literal word that cannot be broken, and wrapping will be done
199
+ # across the strings in the array. In this case, whitespace is not
200
+ # compacted.
201
+ #
202
+ # ### Examples
203
+ #
204
+ # If you pass in a sentence as a simple string, it may be word wrapped
205
+ # when displayed:
206
+ #
207
+ # desc "This sentence may be wrapped."
208
+ #
209
+ # To specify a sentence that should never be word-wrapped, pass it as the
210
+ # sole element of a string array:
211
+ #
212
+ # desc ["This sentence will not be wrapped."]
213
+ #
214
+ # @param desc [String,Array<String>,Toys::WrappableString]
215
+ # @return [self]
216
+ #
217
+ def desc(desc)
218
+ # Source available in the toys-core gem
219
+ end
220
+
221
+ ##
222
+ # Add to the long description for the current flag. The long description
223
+ # is displayed with the flag in online help. This directive may be given
224
+ # multiple times, and the results are cumulative.
225
+ #
226
+ # A long description is a series of descriptions, which are generally
227
+ # displayed in a series of lines/paragraphs. Each individual description
228
+ # uses the form described in the {#desc} documentation, and may be
229
+ # word-wrapped when displayed. To insert a blank line, include an empty
230
+ # string as one of the descriptions.
231
+ #
232
+ # ### Example
233
+ #
234
+ # long_desc "This initial paragraph might get word wrapped.",
235
+ # "This next paragraph is followed by a blank line.",
236
+ # "",
237
+ # ["This line will not be wrapped."],
238
+ # [" This indent is preserved."]
239
+ # long_desc "This line is appended to the description."
240
+ #
241
+ # @param long_desc [String,Array<String>,Toys::WrappableString...]
242
+ # @return [self]
243
+ #
244
+ def long_desc(*long_desc)
245
+ # Source available in the toys-core gem
246
+ end
247
+
248
+ ##
249
+ # Set the group. A group may be set by name or group object. Setting
250
+ # `nil` selects the default group.
251
+ #
252
+ # @param group [String,Symbol,Toys::FlagGroup,nil]
253
+ # @return [self]
254
+ #
255
+ def group(group)
256
+ # Source available in the toys-core gem
257
+ end
258
+
259
+ ##
260
+ # Set the display name for this flag. This may be used in help text and
261
+ # error messages.
262
+ #
263
+ # @param display_name [String]
264
+ # @return [self]
265
+ #
266
+ def display_name(display_name)
267
+ # Source available in the toys-core gem
268
+ end
269
+
270
+ ##
271
+ # Specify whether to add a method for this flag.
272
+ #
273
+ # Recognized values are true to force creation of a method, false to
274
+ # disable method creation, and nil for the default behavior. The default
275
+ # checks the name and adds a method if the name is a symbol representing
276
+ # a legal method name that starts with a letter and does not override any
277
+ # public method in the Ruby Object class or collide with any method
278
+ # directly defined in the tool class.
279
+ #
280
+ # @param value [true,false,nil]
281
+ #
282
+ def add_method(value)
283
+ # Source available in the toys-core gem
284
+ end
285
+ end
286
+ end
287
+ end
@@ -0,0 +1,270 @@
1
+ module Toys
2
+ module DSL
3
+ ##
4
+ # **_Defined in the toys-core gem_**
5
+ #
6
+ # DSL for a flag group definition block. Lets you create flags in a group.
7
+ #
8
+ # These directives are available inside a block passed to
9
+ # {Toys::DSL::Tool#flag_group}, {Toys::DSL::Tool#all_required},
10
+ # {Toys::DSL::Tool#at_most_one}, {Toys::DSL::Tool#at_least_one}, or
11
+ # {Toys::DSL::Tool#exactly_one}.
12
+ #
13
+ # ### Example
14
+ #
15
+ # tool "login" do
16
+ # all_required do
17
+ # # The directives in here are defined by this class
18
+ # flag :username, "--username=VAL", desc: "Set username (required)"
19
+ # flag :password, "--password=VAL", desc: "Set password (required)"
20
+ # end
21
+ # # ...
22
+ # end
23
+ #
24
+ class FlagGroup
25
+ ##
26
+ # Add a flag to the current group. Each flag must specify a key which
27
+ # the script may use to obtain the flag value from the context.
28
+ # You may then provide the flags themselves in OptionParser form.
29
+ #
30
+ # If the given key is a symbol representing a valid method name, then a
31
+ # helper method is automatically added to retrieve the value. Otherwise,
32
+ # if the key is a string or does not represent a valid method name, the
33
+ # tool can retrieve the value by calling {Toys::Context#get}.
34
+ #
35
+ # Attributes of the flag may be passed in as arguments to this method, or
36
+ # set in a block passed to this method. If you provide a block, you can
37
+ # use directives in {Toys::DSL::Flag} within the block.
38
+ #
39
+ # ### Flag syntax
40
+ #
41
+ # The flags themselves should be provided in OptionParser form. Following
42
+ # are examples of valid syntax.
43
+ #
44
+ # * `-a` : A short boolean switch. When this appears as an argument,
45
+ # the value is set to `true`.
46
+ # * `--abc` : A long boolean switch. When this appears as an argument,
47
+ # the value is set to `true`.
48
+ # * `-aVAL` or `-a VAL` : A short flag that takes a required value.
49
+ # These two forms are treated identically. If this argument appears
50
+ # with a value attached (e.g. `-afoo`), the attached string (e.g.
51
+ # `"foo"`) is taken as the value. Otherwise, the following argument
52
+ # is taken as the value (e.g. for `-a foo`, the value is set to
53
+ # `"foo"`.) The following argument is treated as the value even if it
54
+ # looks like a flag (e.g. `-a -a` causes the string `"-a"` to be
55
+ # taken as the value.)
56
+ # * `-a[VAL]` : A short flag that takes an optional value. If this
57
+ # argument appears with a value attached (e.g. `-afoo`), the attached
58
+ # string (e.g. `"foo"`) is taken as the value. Otherwise, the value
59
+ # is set to `true`. The following argument is never interpreted as
60
+ # the value. (Compare with `-a [VAL]`.)
61
+ # * `-a [VAL]` : A short flag that takes an optional value. If this
62
+ # argument appears with a value attached (e.g. `-afoo`), the attached
63
+ # string (e.g. `"foo"`) is taken as the value. Otherwise, if the
64
+ # following argument does not look like a flag (i.e. it does not
65
+ # begin with a hyphen), it is taken as the value. (e.g. `-a foo`
66
+ # causes the string `"foo"` to be taken as the value.). If there is
67
+ # no following argument, or the following argument looks like a flag,
68
+ # the value is set to `true`. (Compare with `-a[VAL]`.)
69
+ # * `--abc=VAL` or `--abc VAL` : A long flag that takes a required
70
+ # value. These two forms are treated identically. If this argument
71
+ # appears with a value attached (e.g. `--abc=foo`), the attached
72
+ # string (e.g. `"foo"`) is taken as the value. Otherwise, the
73
+ # following argument is taken as the value (e.g. for `--abc foo`, the
74
+ # value is set to `"foo"`.) The following argument is treated as the
75
+ # value even if it looks like a flag (e.g. `--abc --def` causes the
76
+ # string `"--def"` to be taken as the value.)
77
+ # * `--abc[=VAL]` : A long flag that takes an optional value. If this
78
+ # argument appears with a value attached (e.g. `--abc=foo`), the
79
+ # attached string (e.g. `"foo"`) is taken as the value. Otherwise,
80
+ # the value is set to `true`. The following argument is never
81
+ # interpreted as the value. (Compare with `--abc [VAL]`.)
82
+ # * `--abc [VAL]` : A long flag that takes an optional value. If this
83
+ # argument appears with a value attached (e.g. `--abc=foo`), the
84
+ # attached string (e.g. `"foo"`) is taken as the value. Otherwise, if
85
+ # the following argument does not look like a flag (i.e. it does not
86
+ # begin with a hyphen), it is taken as the value. (e.g. `--abc foo`
87
+ # causes the string `"foo"` to be taken as the value.). If there is
88
+ # no following argument, or the following argument looks like a flag,
89
+ # the value is set to `true`. (Compare with `--abc=[VAL]`.)
90
+ # * `--[no-]abc` : A long boolean switch that can be turned either on
91
+ # or off. This effectively creates two flags, `--abc` which sets the
92
+ # value to `true`, and `--no-abc` which sets the falue to `false`.
93
+ #
94
+ # ### Default flag syntax
95
+ #
96
+ # If no flag syntax strings are provided, a default syntax will be
97
+ # inferred based on the key and other options.
98
+ #
99
+ # Specifically, if the key has one character, then that character will be
100
+ # chosen as a short flag. If the key has multiple characters, a long flag
101
+ # will be generated.
102
+ #
103
+ # Furthermore, if a custom completion, a non-boolean acceptor, or a
104
+ # non-boolean default value is provided in the options, then the flag
105
+ # will be considered to take a value. Otherwise, it will be considered to
106
+ # be a boolean switch.
107
+ #
108
+ # For example, the following pairs of flags are identical:
109
+ #
110
+ # flag :a
111
+ # flag :a, "-a"
112
+ #
113
+ # flag :abc_def
114
+ # flag :abc_def, "--abc-def"
115
+ #
116
+ # flag :number, accept: Integer
117
+ # flag :number, "--number=VAL", accept: Integer
118
+ #
119
+ # ### More examples
120
+ #
121
+ # A flag that sets its value to the number of times it appears on the
122
+ # command line:
123
+ #
124
+ # flag :verbose, "-v", "--verbose",
125
+ # default: 0, handler: ->(_val, count) { count + 1 }
126
+ #
127
+ # An example using block form:
128
+ #
129
+ # flag :shout do
130
+ # flags "-s", "--shout"
131
+ # default false
132
+ # desc "Say it louder"
133
+ # long_desc "This flag says it lowder.",
134
+ # "You might use this when people can't hear you.",
135
+ # "",
136
+ # "Example:",
137
+ # [" toys say --shout hello"]
138
+ # end
139
+ #
140
+ # @param key [String,Symbol] The key to use to retrieve the value from
141
+ # the execution context.
142
+ # @param flags [String...] The flags in OptionParser format.
143
+ # @param accept [Object] An acceptor that validates and/or converts the
144
+ # value. You may provide either the name of an acceptor you have
145
+ # defined, or one of the default acceptors provided by OptionParser.
146
+ # Optional. If not specified, accepts any value as a string.
147
+ # @param default [Object] The default value. This is the value that will
148
+ # be set in the context if this flag is not provided on the command
149
+ # line. Defaults to `nil`.
150
+ # @param handler [Proc,nil,:set,:push] An optional handler that
151
+ # customizes how a value is set or updated when the flag is parsed.
152
+ # A handler is a proc that takes up to three arguments: the given
153
+ # value, the previous value, and a hash containing all the data
154
+ # collected so far during argument parsing. The proc must return the
155
+ # new value for the flag.
156
+ # You may also specify a predefined named handler. The `:set` handler
157
+ # (the default) replaces the previous value (effectively
158
+ # `-> (val) { val }`). The `:push` handler expects the previous value
159
+ # to be an array and pushes the given value onto it; it should be
160
+ # combined with setting the default value to `[]` and is intended for
161
+ # "multi-valued" flags.
162
+ # @param complete_flags [Object] A specifier for shell tab completion
163
+ # for flag names associated with this flag. By default, a
164
+ # {Toys::Flag::DefaultCompletion} is used, which provides the flag's
165
+ # names as completion candidates. To customize completion, set this
166
+ # to the name of a previously defined completion, a hash of options
167
+ # to pass to the constructor for {Toys::Flag::DefaultCompletion}, or
168
+ # any other spec recognized by {Toys::Completion.create}.
169
+ # @param complete_values [Object] A specifier for shell tab completion
170
+ # for flag values associated with this flag. This is the empty
171
+ # completion by default. To customize completion, set this to the
172
+ # name of a previously defined completion, or any spec recognized by
173
+ # {Toys::Completion.create}.
174
+ # @param report_collisions [Boolean] Raise an exception if a flag is
175
+ # requested that is already in use or marked as unusable. Default is
176
+ # true.
177
+ # @param desc [String,Array<String>,Toys::WrappableString] Short
178
+ # description for the flag. See {Toys::DSL::Tool#desc} for a
179
+ # description of the allowed formats. Defaults to the empty string.
180
+ # @param long_desc [Array<String,Array<String>,Toys::WrappableString>]
181
+ # Long description for the flag. See {Toys::DSL::Tool#long_desc} for
182
+ # a description of the allowed formats. (But note that this param
183
+ # takes an Array of description lines, rather than a series of
184
+ # arguments.) Defaults to the empty array.
185
+ # @param display_name [String] A display name for this flag, used in help
186
+ # text and error messages.
187
+ # @param add_method [true,false,nil] Whether to add a method for this
188
+ # flag. If omitted or set to nil, uses the default behavior, which
189
+ # adds the method if the key is a symbol representing a legal method
190
+ # name that starts with a letter and does not override any public
191
+ # method in the Ruby Object class or collide with any method directly
192
+ # defined in the tool class.
193
+ # @param block [Proc] Configures the flag. See {Toys::DSL::Flag} for the
194
+ # directives that can be called in this block.
195
+ # @return [self]
196
+ #
197
+ def flag(key, *flags,
198
+ accept: nil, default: nil, handler: nil,
199
+ complete_flags: nil, complete_values: nil,
200
+ report_collisions: true, desc: nil, long_desc: nil,
201
+ display_name: nil, add_method: nil,
202
+ &block)
203
+ # Source available in the toys-core gem
204
+ end
205
+
206
+ ##
207
+ # Set the short description for the current flag group. The short
208
+ # description is displayed as the group title in online help.
209
+ #
210
+ # The description is a {Toys::WrappableString}, which may be word-wrapped
211
+ # when displayed in a help screen. You may pass a {Toys::WrappableString}
212
+ # directly to this method, or you may pass any input that can be used to
213
+ # construct a wrappable string:
214
+ #
215
+ # * If you pass a String, its whitespace will be compacted (i.e. tabs,
216
+ # newlines, and multiple consecutive whitespace will be turned into a
217
+ # single space), and it will be word-wrapped on whitespace.
218
+ # * If you pass an Array of Strings, each string will be considered a
219
+ # literal word that cannot be broken, and wrapping will be done
220
+ # across the strings in the array. In this case, whitespace is not
221
+ # compacted.
222
+ #
223
+ # ### Examples
224
+ #
225
+ # If you pass in a sentence as a simple string, it may be word wrapped
226
+ # when displayed:
227
+ #
228
+ # desc "This sentence may be wrapped."
229
+ #
230
+ # To specify a sentence that should never be word-wrapped, pass it as the
231
+ # sole element of a string array:
232
+ #
233
+ # desc ["This sentence will not be wrapped."]
234
+ #
235
+ # @param desc [String,Array<String>,Toys::WrappableString]
236
+ # @return [self]
237
+ #
238
+ def desc(desc)
239
+ # Source available in the toys-core gem
240
+ end
241
+
242
+ ##
243
+ # Add to the long description for the current flag group. The long
244
+ # description is displayed with the flag group in online help. This
245
+ # directive may be given multiple times, and the results are cumulative.
246
+ #
247
+ # A long description is a series of descriptions, which are generally
248
+ # displayed in a series of lines/paragraphs. Each individual description
249
+ # uses the form described in the {#desc} documentation, and may be
250
+ # word-wrapped when displayed. To insert a blank line, include an empty
251
+ # string as one of the descriptions.
252
+ #
253
+ # ### Example
254
+ #
255
+ # long_desc "This initial paragraph might get word wrapped.",
256
+ # "This next paragraph is followed by a blank line.",
257
+ # "",
258
+ # ["This line will not be wrapped."],
259
+ # [" This indent is preserved."]
260
+ # long_desc "This line is appended to the description."
261
+ #
262
+ # @param long_desc [String,Array<String>,Toys::WrappableString...]
263
+ # @return [self]
264
+ #
265
+ def long_desc(*long_desc)
266
+ # Source available in the toys-core gem
267
+ end
268
+ end
269
+ end
270
+ end
@@ -0,0 +1,4 @@
1
+ module Toys
2
+ module DSL
3
+ end
4
+ end