toys 0.12.2 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -0
- data/CHANGELOG.md +35 -0
- data/LICENSE.md +1 -1
- data/README.md +7 -4
- data/builtins/system/git-cache.rb +238 -0
- data/builtins/system/test.rb +37 -2
- data/core-docs/toys/acceptor.rb +432 -0
- data/core-docs/toys/arg_parser.rb +397 -0
- data/core-docs/toys/cli.rb +493 -0
- data/core-docs/toys/compat.rb +2 -0
- data/core-docs/toys/completion.rb +329 -0
- data/core-docs/toys/context.rb +321 -0
- data/core-docs/toys/core.rb +14 -0
- data/core-docs/toys/dsl/base.rb +56 -0
- data/core-docs/toys/dsl/flag.rb +261 -0
- data/core-docs/toys/dsl/flag_group.rb +259 -0
- data/core-docs/toys/dsl/internal.rb +4 -0
- data/core-docs/toys/dsl/positional_arg.rb +139 -0
- data/core-docs/toys/dsl/tool.rb +1530 -0
- data/core-docs/toys/errors.rb +93 -0
- data/core-docs/toys/flag.rb +549 -0
- data/core-docs/toys/flag_group.rb +186 -0
- data/core-docs/toys/input_file.rb +8 -0
- data/core-docs/toys/loader.rb +222 -0
- data/core-docs/toys/middleware.rb +295 -0
- data/core-docs/toys/mixin.rb +142 -0
- data/core-docs/toys/module_lookup.rb +75 -0
- data/core-docs/toys/positional_arg.rb +145 -0
- data/core-docs/toys/settings.rb +507 -0
- data/core-docs/toys/source_info.rb +127 -0
- data/core-docs/toys/standard_middleware/add_verbosity_flags.rb +49 -0
- data/core-docs/toys/standard_middleware/apply_config.rb +24 -0
- data/core-docs/toys/standard_middleware/handle_usage_errors.rb +33 -0
- data/core-docs/toys/standard_middleware/set_default_descriptions.rb +222 -0
- data/core-docs/toys/standard_middleware/show_help.rb +190 -0
- data/core-docs/toys/standard_middleware/show_root_version.rb +45 -0
- data/core-docs/toys/standard_mixins/bundler.rb +83 -0
- data/core-docs/toys/standard_mixins/exec.rb +645 -0
- data/core-docs/toys/standard_mixins/fileutils.rb +18 -0
- data/core-docs/toys/standard_mixins/gems.rb +48 -0
- data/core-docs/toys/standard_mixins/git_cache.rb +41 -0
- data/core-docs/toys/standard_mixins/highline.rb +133 -0
- data/core-docs/toys/standard_mixins/terminal.rb +135 -0
- data/core-docs/toys/standard_mixins/xdg.rb +49 -0
- data/core-docs/toys/template.rb +112 -0
- data/core-docs/toys/tool_definition.rb +926 -0
- data/core-docs/toys/utils/completion_engine.rb +49 -0
- data/core-docs/toys/utils/exec.rb +721 -0
- data/core-docs/toys/utils/gems.rb +185 -0
- data/core-docs/toys/utils/git_cache.rb +353 -0
- data/core-docs/toys/utils/help_text.rb +134 -0
- data/core-docs/toys/utils/terminal.rb +310 -0
- data/core-docs/toys/utils/xdg.rb +253 -0
- data/core-docs/toys/wrappable_string.rb +120 -0
- data/core-docs/toys-core.rb +63 -0
- data/docs/guide.md +497 -156
- data/lib/toys/standard_cli.rb +50 -36
- data/lib/toys/templates/clean.rb +18 -0
- data/lib/toys/templates/gem_build.rb +24 -0
- data/lib/toys/templates/minitest.rb +21 -0
- data/lib/toys/templates/rake.rb +23 -3
- data/lib/toys/templates/rdoc.rb +29 -0
- data/lib/toys/templates/rspec.rb +32 -4
- data/lib/toys/templates/rubocop.rb +14 -1
- data/lib/toys/templates/yardoc.rb +55 -0
- data/lib/toys/testing.rb +186 -109
- data/lib/toys/version.rb +1 -1
- data/lib/toys.rb +4 -2
- metadata +56 -6
@@ -0,0 +1,93 @@
|
|
1
|
+
module Toys
|
2
|
+
##
|
3
|
+
# **_Defined in the toys-core gem_**
|
4
|
+
#
|
5
|
+
# An exception indicating an error in a tool definition.
|
6
|
+
#
|
7
|
+
class ToolDefinitionError < ::StandardError
|
8
|
+
end
|
9
|
+
|
10
|
+
##
|
11
|
+
# **_Defined in the toys-core gem_**
|
12
|
+
#
|
13
|
+
# An exception indicating that a tool has no run method.
|
14
|
+
#
|
15
|
+
class NotRunnableError < ::StandardError
|
16
|
+
end
|
17
|
+
|
18
|
+
##
|
19
|
+
# **_Defined in the toys-core gem_**
|
20
|
+
#
|
21
|
+
# An exception indicating problems parsing arguments.
|
22
|
+
#
|
23
|
+
class ArgParsingError < ::StandardError
|
24
|
+
##
|
25
|
+
# Create an ArgParsingError given a set of error messages
|
26
|
+
# @param errors [Array<Toys::ArgParser::UsageError>]
|
27
|
+
#
|
28
|
+
def initialize(errors)
|
29
|
+
# Source available in the toys-core gem
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# The individual usage error messages.
|
34
|
+
# @return [Array<Toys::ArgParser::UsageError>]
|
35
|
+
#
|
36
|
+
attr_reader :usage_errors
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# **_Defined in the toys-core gem_**
|
41
|
+
#
|
42
|
+
# An exception indicating a problem during tool lookup
|
43
|
+
#
|
44
|
+
class LoaderError < ::StandardError
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# **_Defined in the toys-core gem_**
|
49
|
+
#
|
50
|
+
# A wrapper exception used to provide user-oriented context for an error
|
51
|
+
# thrown during tool execution.
|
52
|
+
#
|
53
|
+
class ContextualError < ::StandardError
|
54
|
+
##
|
55
|
+
# The underlying exception
|
56
|
+
# @return [::StandardError]
|
57
|
+
#
|
58
|
+
attr_reader :cause
|
59
|
+
|
60
|
+
##
|
61
|
+
# An overall banner message
|
62
|
+
# @return [String]
|
63
|
+
#
|
64
|
+
attr_reader :banner
|
65
|
+
|
66
|
+
##
|
67
|
+
# The path to the toys config file in which the error was detected
|
68
|
+
# @return [String]
|
69
|
+
#
|
70
|
+
attr_reader :config_path
|
71
|
+
|
72
|
+
##
|
73
|
+
# The line number in the toys config file in which the error was detected
|
74
|
+
# @return [Integer]
|
75
|
+
#
|
76
|
+
attr_reader :config_line
|
77
|
+
|
78
|
+
##
|
79
|
+
# The full name of the tool that was running when the error occurred
|
80
|
+
# @return [Array<String>]
|
81
|
+
#
|
82
|
+
attr_reader :tool_name
|
83
|
+
|
84
|
+
##
|
85
|
+
# The arguments passed to the tool that was running when the error occurred
|
86
|
+
# @return [Array<String>]
|
87
|
+
#
|
88
|
+
attr_reader :tool_args
|
89
|
+
|
90
|
+
class << self
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,549 @@
|
|
1
|
+
module Toys
|
2
|
+
##
|
3
|
+
# **_Defined in the toys-core gem_**
|
4
|
+
#
|
5
|
+
# Representation of a formal set of flags that set a particular context
|
6
|
+
# key. The flags within a single Flag definition are synonyms.
|
7
|
+
#
|
8
|
+
class Flag
|
9
|
+
##
|
10
|
+
# **_Defined in the toys-core gem_**
|
11
|
+
#
|
12
|
+
# Representation of a single flag.
|
13
|
+
#
|
14
|
+
class Syntax
|
15
|
+
# rubocop:disable Style/PerlBackrefs
|
16
|
+
|
17
|
+
##
|
18
|
+
# Parse flag syntax
|
19
|
+
# @param str [String] syntax.
|
20
|
+
#
|
21
|
+
def initialize(str)
|
22
|
+
# Source available in the toys-core gem
|
23
|
+
end
|
24
|
+
|
25
|
+
# rubocop:enable Style/PerlBackrefs
|
26
|
+
|
27
|
+
##
|
28
|
+
# The original string that was parsed to produce this syntax.
|
29
|
+
# @return [String]
|
30
|
+
#
|
31
|
+
attr_reader :original_str
|
32
|
+
|
33
|
+
##
|
34
|
+
# The flags (without values) corresponding to this syntax.
|
35
|
+
# @return [Array<String>]
|
36
|
+
#
|
37
|
+
attr_reader :flags
|
38
|
+
|
39
|
+
##
|
40
|
+
# The flag (without values) corresponding to the normal "positive" form
|
41
|
+
# of this flag.
|
42
|
+
# @return [String]
|
43
|
+
#
|
44
|
+
attr_reader :positive_flag
|
45
|
+
|
46
|
+
##
|
47
|
+
# The flag (without values) corresponding to the "negative" form of this
|
48
|
+
# flag, if any. i.e. if the original string was `"--[no-]abc"`, the
|
49
|
+
# negative flag is `"--no-abc"`.
|
50
|
+
# @return [String] The negative form.
|
51
|
+
# @return [nil] if the flag has no negative form.
|
52
|
+
#
|
53
|
+
attr_reader :negative_flag
|
54
|
+
|
55
|
+
##
|
56
|
+
# The original string with the value (if any) stripped, but retaining
|
57
|
+
# the `[no-]` prefix if present.
|
58
|
+
# @return [String]
|
59
|
+
#
|
60
|
+
attr_reader :str_without_value
|
61
|
+
|
62
|
+
##
|
63
|
+
# A string used to sort this flag compared with others.
|
64
|
+
# @return [String]
|
65
|
+
#
|
66
|
+
attr_reader :sort_str
|
67
|
+
|
68
|
+
##
|
69
|
+
# The style of flag (`:long` or `:short`).
|
70
|
+
# @return [:long] if this is a long flag (i.e. double hyphen)
|
71
|
+
# @return [:short] if this is a short flag (i.e. single hyphen with one
|
72
|
+
# character).
|
73
|
+
#
|
74
|
+
attr_reader :flag_style
|
75
|
+
|
76
|
+
##
|
77
|
+
# The type of flag (`:boolean` or `:value`)
|
78
|
+
# @return [:boolean] if this is a boolean flag (i.e. no value)
|
79
|
+
# @return [:value] if this flag takes a value (even if optional)
|
80
|
+
#
|
81
|
+
attr_reader :flag_type
|
82
|
+
|
83
|
+
##
|
84
|
+
# The type of value (`:required` or `:optional`)
|
85
|
+
# @return [:required] if this flag takes a required value
|
86
|
+
# @return [:optional] if this flag takes an optional value
|
87
|
+
# @return [nil] if this flag is a boolean flag
|
88
|
+
#
|
89
|
+
attr_reader :value_type
|
90
|
+
|
91
|
+
##
|
92
|
+
# The default delimiter used for the value of this flag. This could be
|
93
|
+
# `""` or `" "` for a short flag, or `" "` or `"="` for a long flag.
|
94
|
+
# @return [String] delimiter
|
95
|
+
# @return [nil] if this flag is a boolean flag
|
96
|
+
#
|
97
|
+
attr_reader :value_delim
|
98
|
+
|
99
|
+
##
|
100
|
+
# The default "label" for the value. e.g. in `--abc=VAL` the label is
|
101
|
+
# `"VAL"`.
|
102
|
+
# @return [String] the label
|
103
|
+
# @return [nil] if this flag is a boolean flag
|
104
|
+
#
|
105
|
+
attr_reader :value_label
|
106
|
+
|
107
|
+
##
|
108
|
+
# A canonical string representing this flag's syntax, normalized to match
|
109
|
+
# the type, delimiters, etc. settings of other flag syntaxes. This is
|
110
|
+
# generally used in help strings to represent this flag.
|
111
|
+
# @return [String]
|
112
|
+
#
|
113
|
+
attr_reader :canonical_str
|
114
|
+
end
|
115
|
+
|
116
|
+
##
|
117
|
+
# **_Defined in the toys-core gem_**
|
118
|
+
#
|
119
|
+
# The result of looking up a flag by name.
|
120
|
+
#
|
121
|
+
class Resolution
|
122
|
+
##
|
123
|
+
# The flag string that was looked up
|
124
|
+
# @return [String]
|
125
|
+
#
|
126
|
+
attr_reader :string
|
127
|
+
|
128
|
+
##
|
129
|
+
# Whether an exact match of the string was found
|
130
|
+
# @return [Boolean]
|
131
|
+
#
|
132
|
+
def found_exact?
|
133
|
+
# Source available in the toys-core gem
|
134
|
+
end
|
135
|
+
|
136
|
+
##
|
137
|
+
# The number of matches that were found.
|
138
|
+
# @return [Integer]
|
139
|
+
#
|
140
|
+
def count
|
141
|
+
# Source available in the toys-core gem
|
142
|
+
end
|
143
|
+
|
144
|
+
##
|
145
|
+
# Whether a single unique match was found.
|
146
|
+
# @return [Boolean]
|
147
|
+
#
|
148
|
+
def found_unique?
|
149
|
+
# Source available in the toys-core gem
|
150
|
+
end
|
151
|
+
|
152
|
+
##
|
153
|
+
# Whether no matches were found.
|
154
|
+
# @return [Boolean]
|
155
|
+
#
|
156
|
+
def not_found?
|
157
|
+
# Source available in the toys-core gem
|
158
|
+
end
|
159
|
+
|
160
|
+
##
|
161
|
+
# Whether multiple matches were found (i.e. ambiguous input).
|
162
|
+
# @return [Boolean]
|
163
|
+
#
|
164
|
+
def found_multiple?
|
165
|
+
# Source available in the toys-core gem
|
166
|
+
end
|
167
|
+
|
168
|
+
##
|
169
|
+
# Return the unique {Toys::Flag}, or `nil` if not found or
|
170
|
+
# not unique.
|
171
|
+
# @return [Toys::Flag,nil]
|
172
|
+
#
|
173
|
+
def unique_flag
|
174
|
+
# Source available in the toys-core gem
|
175
|
+
end
|
176
|
+
|
177
|
+
##
|
178
|
+
# Return the unique {Toys::Flag::Syntax}, or `nil` if not found
|
179
|
+
# or not unique.
|
180
|
+
# @return [Toys::Flag::Syntax,nil]
|
181
|
+
#
|
182
|
+
def unique_flag_syntax
|
183
|
+
# Source available in the toys-core gem
|
184
|
+
end
|
185
|
+
|
186
|
+
##
|
187
|
+
# Return whether the unique match was a hit on the negative (`--no-*`)
|
188
|
+
# case, or `nil` if not found or not unique.
|
189
|
+
# @return [Boolean,nil]
|
190
|
+
#
|
191
|
+
def unique_flag_negative?
|
192
|
+
# Source available in the toys-core gem
|
193
|
+
end
|
194
|
+
|
195
|
+
##
|
196
|
+
# Returns an array of the matching full flag strings.
|
197
|
+
# @return [Array<String>]
|
198
|
+
#
|
199
|
+
def matching_flag_strings
|
200
|
+
# Source available in the toys-core gem
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
##
|
205
|
+
# **_Defined in the toys-core gem_**
|
206
|
+
#
|
207
|
+
# A Completion that returns all possible flags associated with a
|
208
|
+
# {Toys::Flag}.
|
209
|
+
#
|
210
|
+
class DefaultCompletion < Completion::Base
|
211
|
+
##
|
212
|
+
# Create a completion given configuration options.
|
213
|
+
#
|
214
|
+
# @param flag [Toys::Flag] The flag definition.
|
215
|
+
# @param include_short [Boolean] Whether to include short flags.
|
216
|
+
# @param include_long [Boolean] Whether to include long flags.
|
217
|
+
# @param include_negative [Boolean] Whether to include `--no-*` forms.
|
218
|
+
#
|
219
|
+
def initialize(flag:, include_short: true, include_long: true, include_negative: true)
|
220
|
+
# Source available in the toys-core gem
|
221
|
+
end
|
222
|
+
|
223
|
+
##
|
224
|
+
# Whether to include short flags
|
225
|
+
# @return [Boolean]
|
226
|
+
#
|
227
|
+
def include_short?
|
228
|
+
# Source available in the toys-core gem
|
229
|
+
end
|
230
|
+
|
231
|
+
##
|
232
|
+
# Whether to include long flags
|
233
|
+
# @return [Boolean]
|
234
|
+
#
|
235
|
+
def include_long?
|
236
|
+
# Source available in the toys-core gem
|
237
|
+
end
|
238
|
+
|
239
|
+
##
|
240
|
+
# Whether to include negative long flags
|
241
|
+
# @return [Boolean]
|
242
|
+
#
|
243
|
+
def include_negative?
|
244
|
+
# Source available in the toys-core gem
|
245
|
+
end
|
246
|
+
|
247
|
+
##
|
248
|
+
# Returns candidates for the current completion.
|
249
|
+
#
|
250
|
+
# @param context [Toys::Completion::Context] the current completion
|
251
|
+
# context including the string fragment.
|
252
|
+
# @return [Array<Toys::Completion::Candidate>] an array of candidates
|
253
|
+
#
|
254
|
+
def call(context)
|
255
|
+
# Source available in the toys-core gem
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
##
|
260
|
+
# The set handler replaces the previous value.
|
261
|
+
# @return [Proc]
|
262
|
+
#
|
263
|
+
SET_HANDLER = ->(val, _prev) { val }
|
264
|
+
|
265
|
+
##
|
266
|
+
# The push handler pushes the given value using the `<<` operator.
|
267
|
+
# @return [Proc]
|
268
|
+
#
|
269
|
+
PUSH_HANDLER = ->(val, prev) { prev.nil? ? [val] : prev << val }
|
270
|
+
|
271
|
+
##
|
272
|
+
# The default handler is the set handler, replacing the previous value.
|
273
|
+
# @return [Proc]
|
274
|
+
#
|
275
|
+
DEFAULT_HANDLER = SET_HANDLER
|
276
|
+
|
277
|
+
##
|
278
|
+
# Create a flag definition.
|
279
|
+
#
|
280
|
+
# @param key [String,Symbol] The key to use to retrieve the value from
|
281
|
+
# the execution context.
|
282
|
+
# @param flags [Array<String>] The flags in OptionParser format. If empty,
|
283
|
+
# a flag will be inferred from the key.
|
284
|
+
# @param accept [Object] An acceptor that validates and/or converts the
|
285
|
+
# value. See {Toys::Acceptor.create} for recognized formats. Optional.
|
286
|
+
# If not specified, defaults to {Toys::Acceptor::DEFAULT}.
|
287
|
+
# @param default [Object] The default value. This is the value that will
|
288
|
+
# be set in the context if this flag is not provided on the command
|
289
|
+
# line. Defaults to `nil`.
|
290
|
+
# @param handler [Proc,nil,:set,:push] An optional handler for
|
291
|
+
# setting/updating the value. A handler is a proc taking two
|
292
|
+
# arguments, the given value and the previous value, returning the
|
293
|
+
# new value that should be set. You may also specify a predefined
|
294
|
+
# named handler. The `:set` handler (the default) replaces the
|
295
|
+
# previous value (effectively `-> (val, _prev) { val }`). The
|
296
|
+
# `:push` handler expects the previous value to be an array and
|
297
|
+
# pushes the given value onto it; it should be combined with setting
|
298
|
+
# `default: []` and is intended for "multi-valued" flags.
|
299
|
+
# @param complete_flags [Object] A specifier for shell tab completion for
|
300
|
+
# flag names associated with this flag. By default, a
|
301
|
+
# {Toys::Flag::DefaultCompletion} is used, which provides the flag's
|
302
|
+
# names as completion candidates. To customize completion, set this to
|
303
|
+
# a hash of options to pass to the constructor for
|
304
|
+
# {Toys::Flag::DefaultCompletion}, or pass any other spec recognized
|
305
|
+
# by {Toys::Completion.create}.
|
306
|
+
# @param complete_values [Object] A specifier for shell tab completion for
|
307
|
+
# flag values associated with this flag. Pass any spec recognized by
|
308
|
+
# {Toys::Completion.create}.
|
309
|
+
# @param report_collisions [Boolean] Raise an exception if a flag is
|
310
|
+
# requested that is already in use or marked as disabled. Default is
|
311
|
+
# true.
|
312
|
+
# @param group [Toys::FlagGroup] Group containing this flag.
|
313
|
+
# @param desc [String,Array<String>,Toys::WrappableString] Short
|
314
|
+
# description for the flag. See {Toys::ToolDefinition#desc} for a
|
315
|
+
# description of allowed formats. Defaults to the empty string.
|
316
|
+
# @param long_desc [Array<String,Array<String>,Toys::WrappableString>]
|
317
|
+
# Long description for the flag. See {Toys::ToolDefinition#long_desc}
|
318
|
+
# for a description of allowed formats. Defaults to the empty array.
|
319
|
+
# @param display_name [String] A display name for this flag, used in help
|
320
|
+
# text and error messages.
|
321
|
+
# @param used_flags [Array<String>] An array of flags already in use.
|
322
|
+
#
|
323
|
+
def self.create(key, flags = [],
|
324
|
+
used_flags: nil, report_collisions: true, accept: nil, handler: nil,
|
325
|
+
default: nil, complete_flags: nil, complete_values: nil, display_name: nil,
|
326
|
+
desc: nil, long_desc: nil, group: nil)
|
327
|
+
# Source available in the toys-core gem
|
328
|
+
end
|
329
|
+
|
330
|
+
##
|
331
|
+
# Returns the flag group containing this flag
|
332
|
+
# @return [Toys::FlagGroup]
|
333
|
+
#
|
334
|
+
attr_reader :group
|
335
|
+
|
336
|
+
##
|
337
|
+
# Returns the key.
|
338
|
+
# @return [Symbol]
|
339
|
+
#
|
340
|
+
attr_reader :key
|
341
|
+
|
342
|
+
##
|
343
|
+
# Returns an array of Flag::Syntax for the flags.
|
344
|
+
# @return [Array<Toys::Flag::Syntax>]
|
345
|
+
#
|
346
|
+
attr_reader :flag_syntax
|
347
|
+
|
348
|
+
##
|
349
|
+
# Returns the effective acceptor.
|
350
|
+
# @return [Toys::Acceptor::Base]
|
351
|
+
#
|
352
|
+
attr_reader :acceptor
|
353
|
+
|
354
|
+
##
|
355
|
+
# Returns the default value, which may be `nil`.
|
356
|
+
# @return [Object]
|
357
|
+
#
|
358
|
+
attr_reader :default
|
359
|
+
|
360
|
+
##
|
361
|
+
# The short description string.
|
362
|
+
#
|
363
|
+
# When reading, this is always returned as a {Toys::WrappableString}.
|
364
|
+
#
|
365
|
+
# When setting, the description may be provided as any of the following:
|
366
|
+
# * A {Toys::WrappableString}.
|
367
|
+
# * A normal String, which will be transformed into a
|
368
|
+
# {Toys::WrappableString} using spaces as word delimiters.
|
369
|
+
# * An Array of String, which will be transformed into a
|
370
|
+
# {Toys::WrappableString} where each array element represents an
|
371
|
+
# individual word for wrapping.
|
372
|
+
#
|
373
|
+
# @return [Toys::WrappableString]
|
374
|
+
#
|
375
|
+
attr_reader :desc
|
376
|
+
|
377
|
+
##
|
378
|
+
# The long description strings.
|
379
|
+
#
|
380
|
+
# When reading, this is returned as an Array of {Toys::WrappableString}
|
381
|
+
# representing the lines in the description.
|
382
|
+
#
|
383
|
+
# When setting, the description must be provided as an Array where *each
|
384
|
+
# element* may be any of the following:
|
385
|
+
# * A {Toys::WrappableString} representing one line.
|
386
|
+
# * A normal String representing a line. This will be transformed into a
|
387
|
+
# {Toys::WrappableString} using spaces as word delimiters.
|
388
|
+
# * An Array of String representing a line. This will be transformed into
|
389
|
+
# a {Toys::WrappableString} where each array element represents an
|
390
|
+
# individual word for wrapping.
|
391
|
+
#
|
392
|
+
# @return [Array<Toys::WrappableString>]
|
393
|
+
#
|
394
|
+
attr_reader :long_desc
|
395
|
+
|
396
|
+
##
|
397
|
+
# The handler for setting/updating the value.
|
398
|
+
# @return [Proc]
|
399
|
+
#
|
400
|
+
attr_reader :handler
|
401
|
+
|
402
|
+
##
|
403
|
+
# The proc that determines shell completions for the flag.
|
404
|
+
# @return [Proc,Toys::Completion::Base]
|
405
|
+
#
|
406
|
+
attr_reader :flag_completion
|
407
|
+
|
408
|
+
##
|
409
|
+
# The proc that determines shell completions for the value.
|
410
|
+
# @return [Proc,Toys::Completion::Base]
|
411
|
+
#
|
412
|
+
attr_reader :value_completion
|
413
|
+
|
414
|
+
##
|
415
|
+
# The type of flag.
|
416
|
+
#
|
417
|
+
# @return [:boolean] if the flag is a simple boolean switch
|
418
|
+
# @return [:value] if the flag sets a value
|
419
|
+
#
|
420
|
+
attr_reader :flag_type
|
421
|
+
|
422
|
+
##
|
423
|
+
# The type of value.
|
424
|
+
#
|
425
|
+
# @return [:required] if the flag type is `:value` and the value is
|
426
|
+
# required.
|
427
|
+
# @return [:optional] if the flag type is `:value` and the value is
|
428
|
+
# optional.
|
429
|
+
# @return [nil] if the flag type is not `:value`.
|
430
|
+
#
|
431
|
+
attr_reader :value_type
|
432
|
+
|
433
|
+
##
|
434
|
+
# The string label for the value as it should display in help.
|
435
|
+
# @return [String] The label
|
436
|
+
# @return [nil] if the flag type is not `:value`.
|
437
|
+
#
|
438
|
+
attr_reader :value_label
|
439
|
+
|
440
|
+
##
|
441
|
+
# The value delimiter, which may be `""`, `" "`, or `"="`.
|
442
|
+
#
|
443
|
+
# @return [String] The delimiter
|
444
|
+
# @return [nil] if the flag type is not `:value`.
|
445
|
+
#
|
446
|
+
attr_reader :value_delim
|
447
|
+
|
448
|
+
##
|
449
|
+
# The display name of this flag.
|
450
|
+
# @return [String]
|
451
|
+
#
|
452
|
+
attr_reader :display_name
|
453
|
+
|
454
|
+
##
|
455
|
+
# A string that can be used to sort this flag
|
456
|
+
# @return [String]
|
457
|
+
#
|
458
|
+
attr_reader :sort_str
|
459
|
+
|
460
|
+
##
|
461
|
+
# An array of Flag::Syntax including only short (single dash) flags.
|
462
|
+
# @return [Array<Flag::Syntax>]
|
463
|
+
#
|
464
|
+
def short_flag_syntax
|
465
|
+
# Source available in the toys-core gem
|
466
|
+
end
|
467
|
+
|
468
|
+
##
|
469
|
+
# An array of Flag::Syntax including only long (double-dash) flags.
|
470
|
+
# @return [Array<Flag::Syntax>]
|
471
|
+
#
|
472
|
+
def long_flag_syntax
|
473
|
+
# Source available in the toys-core gem
|
474
|
+
end
|
475
|
+
|
476
|
+
##
|
477
|
+
# The list of all effective flags used.
|
478
|
+
# @return [Array<String>]
|
479
|
+
#
|
480
|
+
def effective_flags
|
481
|
+
# Source available in the toys-core gem
|
482
|
+
end
|
483
|
+
|
484
|
+
##
|
485
|
+
# Look up the flag by string. Returns an object that indicates whether
|
486
|
+
# the given string matched this flag, whether the match was unique, and
|
487
|
+
# other pertinent information.
|
488
|
+
#
|
489
|
+
# @param str [String] Flag string to look up
|
490
|
+
# @return [Toys::Flag::Resolution] Information about the match.
|
491
|
+
#
|
492
|
+
def resolve(str)
|
493
|
+
# Source available in the toys-core gem
|
494
|
+
end
|
495
|
+
|
496
|
+
##
|
497
|
+
# A list of canonical flag syntax strings.
|
498
|
+
#
|
499
|
+
# @return [Array<String>]
|
500
|
+
#
|
501
|
+
def canonical_syntax_strings
|
502
|
+
# Source available in the toys-core gem
|
503
|
+
end
|
504
|
+
|
505
|
+
##
|
506
|
+
# Whether this flag is active--that is, it has a nonempty flags list.
|
507
|
+
#
|
508
|
+
# @return [Boolean]
|
509
|
+
#
|
510
|
+
def active?
|
511
|
+
# Source available in the toys-core gem
|
512
|
+
end
|
513
|
+
|
514
|
+
##
|
515
|
+
# Set the short description string.
|
516
|
+
#
|
517
|
+
# See {#desc} for details.
|
518
|
+
#
|
519
|
+
# @param desc [Toys::WrappableString,String,Array<String>]
|
520
|
+
#
|
521
|
+
def desc=(desc)
|
522
|
+
# Source available in the toys-core gem
|
523
|
+
end
|
524
|
+
|
525
|
+
##
|
526
|
+
# Set the long description strings.
|
527
|
+
#
|
528
|
+
# See {#long_desc} for details.
|
529
|
+
#
|
530
|
+
# @param long_desc [Array<Toys::WrappableString,String,Array<String>>]
|
531
|
+
#
|
532
|
+
def long_desc=(long_desc)
|
533
|
+
# Source available in the toys-core gem
|
534
|
+
end
|
535
|
+
|
536
|
+
##
|
537
|
+
# Append long description strings.
|
538
|
+
#
|
539
|
+
# You must pass an array of lines in the long description. See {#long_desc}
|
540
|
+
# for details on how each line may be represented.
|
541
|
+
#
|
542
|
+
# @param long_desc [Array<Toys::WrappableString,String,Array<String>>]
|
543
|
+
# @return [self]
|
544
|
+
#
|
545
|
+
def append_long_desc(long_desc)
|
546
|
+
# Source available in the toys-core gem
|
547
|
+
end
|
548
|
+
end
|
549
|
+
end
|