toys 0.15.6 → 0.16.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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -1
  3. data/README.md +2 -2
  4. data/builtins/system/tools.rb +1 -1
  5. data/lib/toys/templates/clean.rb +1 -1
  6. data/lib/toys/templates/gem_build.rb +1 -1
  7. data/lib/toys/templates/rubocop.rb +4 -1
  8. data/lib/toys/version.rb +1 -1
  9. metadata +8 -63
  10. data/core-docs/toys/acceptor.rb +0 -474
  11. data/core-docs/toys/arg_parser.rb +0 -397
  12. data/core-docs/toys/cli.rb +0 -466
  13. data/core-docs/toys/compat.rb +0 -2
  14. data/core-docs/toys/completion.rb +0 -340
  15. data/core-docs/toys/context.rb +0 -386
  16. data/core-docs/toys/core.rb +0 -14
  17. data/core-docs/toys/dsl/base.rb +0 -56
  18. data/core-docs/toys/dsl/flag.rb +0 -284
  19. data/core-docs/toys/dsl/flag_group.rb +0 -267
  20. data/core-docs/toys/dsl/internal.rb +0 -4
  21. data/core-docs/toys/dsl/positional_arg.rb +0 -155
  22. data/core-docs/toys/dsl/tool.rb +0 -1639
  23. data/core-docs/toys/errors.rb +0 -126
  24. data/core-docs/toys/flag.rb +0 -560
  25. data/core-docs/toys/flag_group.rb +0 -186
  26. data/core-docs/toys/input_file.rb +0 -17
  27. data/core-docs/toys/loader.rb +0 -363
  28. data/core-docs/toys/middleware.rb +0 -336
  29. data/core-docs/toys/mixin.rb +0 -142
  30. data/core-docs/toys/module_lookup.rb +0 -75
  31. data/core-docs/toys/positional_arg.rb +0 -145
  32. data/core-docs/toys/settings.rb +0 -524
  33. data/core-docs/toys/source_info.rb +0 -271
  34. data/core-docs/toys/standard_middleware/add_verbosity_flags.rb +0 -49
  35. data/core-docs/toys/standard_middleware/apply_config.rb +0 -24
  36. data/core-docs/toys/standard_middleware/handle_usage_errors.rb +0 -33
  37. data/core-docs/toys/standard_middleware/set_default_descriptions.rb +0 -222
  38. data/core-docs/toys/standard_middleware/show_help.rb +0 -190
  39. data/core-docs/toys/standard_middleware/show_root_version.rb +0 -45
  40. data/core-docs/toys/standard_mixins/bundler.rb +0 -98
  41. data/core-docs/toys/standard_mixins/exec.rb +0 -711
  42. data/core-docs/toys/standard_mixins/fileutils.rb +0 -18
  43. data/core-docs/toys/standard_mixins/gems.rb +0 -62
  44. data/core-docs/toys/standard_mixins/git_cache.rb +0 -41
  45. data/core-docs/toys/standard_mixins/highline.rb +0 -133
  46. data/core-docs/toys/standard_mixins/pager.rb +0 -50
  47. data/core-docs/toys/standard_mixins/terminal.rb +0 -135
  48. data/core-docs/toys/standard_mixins/xdg.rb +0 -49
  49. data/core-docs/toys/template.rb +0 -112
  50. data/core-docs/toys/tool_definition.rb +0 -1079
  51. data/core-docs/toys/utils/completion_engine.rb +0 -49
  52. data/core-docs/toys/utils/exec.rb +0 -776
  53. data/core-docs/toys/utils/gems.rb +0 -185
  54. data/core-docs/toys/utils/git_cache.rb +0 -353
  55. data/core-docs/toys/utils/help_text.rb +0 -134
  56. data/core-docs/toys/utils/pager.rb +0 -118
  57. data/core-docs/toys/utils/standard_ui.rb +0 -184
  58. data/core-docs/toys/utils/terminal.rb +0 -310
  59. data/core-docs/toys/utils/xdg.rb +0 -253
  60. data/core-docs/toys/wrappable_string.rb +0 -132
  61. data/core-docs/toys-core.rb +0 -111
@@ -1,386 +0,0 @@
1
- module Toys
2
- ##
3
- # **_Defined in the toys-core gem_**
4
- #
5
- # This is the base class for tool execution. It represents `self` when your
6
- # tool's methods (such as `run`) are called, and it defines the methods that
7
- # can be called by your tool (such as {#logger} and {#exit}.)
8
- #
9
- # This class also manages the "data" available to your tool when it runs.
10
- # This data is a hash of key-value pairs. It consists of values set by flags
11
- # and arguments defined by the tool, plus some "well-known" values such as
12
- # the logger and verbosity level.
13
- #
14
- # You can obtain a value from the data using the {Toys::Context#get} method.
15
- # Additionally, convenience methods are provided for many of the well-known
16
- # keys. For instance, you can call {Toys::Context#verbosity} to obtain the
17
- # value for the key {Toys::Context::Key::VERBOSITY}. Finally, flags and
18
- # positional arguments that store their data here will also typically
19
- # generate convenience methods. For example, an argument with key `:abc` will
20
- # add a method called `abc` that you can call to get the value.
21
- #
22
- # By convention, flags and arguments defined by your tool should use strings
23
- # or symbols as keys. Keys that are not strings or symbols should either be
24
- # well-known keys such as {Toys::Context::Key::VERBOSITY}, or should be used
25
- # for internal private information needed by middleware and mixins. The
26
- # module {Toys::Context::Key} defines a number of well-known keys as
27
- # constants.
28
- #
29
- class Context
30
- ##
31
- # **_Defined in the toys-core gem_**
32
- #
33
- # Well-known context keys.
34
- #
35
- # This module is mixed into the runtime context. This means you can
36
- # reference any of these constants directly from your run method.
37
- #
38
- # ### Example
39
- #
40
- # tool "my-name" do
41
- # def run
42
- # # TOOL_NAME is available here.
43
- # puts "My name is #{get(TOOL_NAME)}"
44
- # end
45
- # end
46
- #
47
- module Key
48
- ##
49
- # Context key for the argument list passed to the current tool. Value is
50
- # an array of strings.
51
- # @return [Object]
52
- #
53
- ARGS = ::Object.new.freeze
54
-
55
- ##
56
- # Context key for the currently running {Toys::CLI}. You can use the
57
- # value to run other tools from your tool by calling {Toys::CLI#run}.
58
- # @return [Object]
59
- #
60
- CLI = ::Object.new.freeze
61
-
62
- ##
63
- # Context key for the context directory path. The value is a string
64
- # @return [Object]
65
- #
66
- CONTEXT_DIRECTORY = ::Object.new.freeze
67
-
68
- ##
69
- # Context key for the context from which the current call was delegated.
70
- # The value is either another context object, or `nil` if the current
71
- # call is not delegated.
72
- # @return [Object]
73
- #
74
- DELEGATED_FROM = ::Object.new.freeze
75
-
76
- ##
77
- # Context key for the active `Logger` object.
78
- # @return [Object]
79
- #
80
- LOGGER = ::Object.new.freeze
81
-
82
- ##
83
- # Context key for the {Toys::ToolDefinition} object being executed.
84
- # @return [Object]
85
- #
86
- TOOL = ::Object.new.freeze
87
-
88
- ##
89
- # Context key for the full name of the tool being executed. Value is an
90
- # array of strings.
91
- # @return [Object]
92
- #
93
- TOOL_NAME = ::Object.new.freeze
94
-
95
- ##
96
- # Context key for the {Toys::SourceInfo} describing the source of this
97
- # tool.
98
- # @return [Object]
99
- #
100
- TOOL_SOURCE = ::Object.new.freeze
101
-
102
- ##
103
- # Context key for all unmatched args in order. The value is an array of
104
- # strings.
105
- # @return [Object]
106
- #
107
- UNMATCHED_ARGS = ::Object.new.freeze
108
-
109
- ##
110
- # Context key for unmatched flags. The value is an array of strings.
111
- # @return [Object]
112
- #
113
- UNMATCHED_FLAGS = ::Object.new.freeze
114
-
115
- ##
116
- # Context key for unmatched positional args. The value is an array of
117
- # strings.
118
- # @return [Object]
119
- #
120
- UNMATCHED_POSITIONAL = ::Object.new.freeze
121
-
122
- ##
123
- # Context key for the list of usage errors raised. The value is an array
124
- # of {Toys::ArgParser::UsageError}.
125
- # @return [Object]
126
- #
127
- USAGE_ERRORS = ::Object.new.freeze
128
-
129
- ##
130
- # Context key for the verbosity value. The value is an integer defaulting
131
- # to 0, with higher values meaning more verbose and lower meaning more
132
- # quiet.
133
- # @return [Object]
134
- #
135
- VERBOSITY = ::Object.new.freeze
136
- end
137
-
138
- ##
139
- # The raw arguments passed to the tool, as an array of strings.
140
- # This does not include the tool name itself.
141
- #
142
- # This is a convenience getter for {Toys::Context::Key::ARGS}.
143
- #
144
- # If the `args` method is overridden by the tool, you can still access it
145
- # using the name `__args`.
146
- #
147
- # @return [Array<String>]
148
- #
149
- def args
150
- # Source available in the toys-core gem
151
- end
152
- alias __args args
153
-
154
- ##
155
- # The currently running CLI.
156
- #
157
- # This is a convenience getter for {Toys::Context::Key::CLI}.
158
- #
159
- # If the `cli` method is overridden by the tool, you can still access it
160
- # using the name `__cli`.
161
- #
162
- # @return [Toys::CLI]
163
- #
164
- def cli
165
- # Source available in the toys-core gem
166
- end
167
- alias __cli cli
168
-
169
- ##
170
- # Return the context directory for this tool. Generally, this defaults
171
- # to the directory containing the toys config directory structure being
172
- # read, but it may be changed by setting a different context directory
173
- # for the tool.
174
- #
175
- # This is a convenience getter for {Toys::Context::Key::CONTEXT_DIRECTORY}.
176
- #
177
- # If the `context_directory` method is overridden by the tool, you can
178
- # still access it using the name `__context_directory`.
179
- #
180
- # @return [String] Context directory path
181
- # @return [nil] if there is no context.
182
- #
183
- def context_directory
184
- # Source available in the toys-core gem
185
- end
186
- alias __context_directory context_directory
187
-
188
- ##
189
- # The logger for this execution.
190
- #
191
- # This is a convenience getter for {Toys::Context::Key::LOGGER}.
192
- #
193
- # If the `logger` method is overridden by the tool, you can still access it
194
- # using the name `__logger`.
195
- #
196
- # @return [Logger]
197
- #
198
- def logger
199
- # Source available in the toys-core gem
200
- end
201
- alias __logger logger
202
-
203
- ##
204
- # The full name of the tool being executed, as an array of strings.
205
- #
206
- # This is a convenience getter for {Toys::Context::Key::TOOL_NAME}.
207
- #
208
- # If the `tool_name` method is overridden by the tool, you can still access
209
- # it using the name `__tool_name`.
210
- #
211
- # @return [Array<String>]
212
- #
213
- def tool_name
214
- # Source available in the toys-core gem
215
- end
216
- alias __tool_name tool_name
217
-
218
- ##
219
- # The source of the tool being executed.
220
- #
221
- # This is a convenience getter for {Toys::Context::Key::TOOL_SOURCE}.
222
- #
223
- # If the `tool_source` method is overridden by the tool, you can still
224
- # access it using the name `__tool_source`.
225
- #
226
- # @return [Toys::SourceInfo]
227
- #
228
- def tool_source
229
- # Source available in the toys-core gem
230
- end
231
- alias __tool_source tool_source
232
-
233
- ##
234
- # The (possibly empty) array of errors detected during argument parsing.
235
- #
236
- # This is a convenience getter for {Toys::Context::Key::USAGE_ERRORS}.
237
- #
238
- # If the `usage_errors` method is overridden by the tool, you can still
239
- # access it using the name `__usage_errors`.
240
- #
241
- # @return [Array<Toys::ArgParser::UsageError>]
242
- #
243
- def usage_errors
244
- # Source available in the toys-core gem
245
- end
246
- alias __usage_errors usage_errors
247
-
248
- ##
249
- # The current verbosity setting as an integer.
250
- #
251
- # This is a convenience getter for {Toys::Context::Key::VERBOSITY}.
252
- #
253
- # If the `verbosity` method is overridden by the tool, you can still access
254
- # it using the name `__verbosity`.
255
- #
256
- # @return [Integer]
257
- #
258
- def verbosity
259
- # Source available in the toys-core gem
260
- end
261
- alias __verbosity verbosity
262
-
263
- ##
264
- # Fetch an option or other piece of data by key.
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
- #
269
- # @param key [Symbol]
270
- # @return [Object]
271
- #
272
- def [](key)
273
- # Source available in the toys-core gem
274
- end
275
- alias get []
276
- alias __get []
277
-
278
- ##
279
- # Set an option or other piece of context data by key.
280
- #
281
- # @param key [Symbol]
282
- # @param value [Object]
283
- #
284
- def []=(key, value)
285
- # Source available in the toys-core gem
286
- end
287
-
288
- ##
289
- # Set one or more options or other context data by key.
290
- #
291
- # If the `set` method is overridden by the tool, you can still access it
292
- # using the name `__set`.
293
- #
294
- # @return [self]
295
- #
296
- # @overload set(key, value)
297
- # Set an option or other piece of context data by key.
298
- # @param key [Symbol]
299
- # @param value [Object]
300
- # @return [self]
301
- #
302
- # @overload set(hash)
303
- # Set multiple content data keys and values
304
- # @param hash [Hash] The keys and values to set
305
- # @return [self]
306
- #
307
- def set(key, value = nil)
308
- # Source available in the toys-core gem
309
- end
310
- alias __set set
311
-
312
- ##
313
- # The subset of the context that uses string or symbol keys. By convention,
314
- # this includes keys that are set by tool flags and arguments, but does not
315
- # include well-known context values such as verbosity or private context
316
- # values used by middleware or mixins.
317
- #
318
- # If the `options` method is overridden by the tool, you can still access
319
- # it using the name `__options`.
320
- #
321
- # @return [Hash]
322
- #
323
- def options
324
- # Source available in the toys-core gem
325
- end
326
- alias __options options
327
-
328
- ##
329
- # Find the given data file or directory in this tool's search path.
330
- #
331
- # If the `find_data` method is overridden by the tool, you can still access
332
- # it using the name `__find_data`.
333
- #
334
- # @param path [String] The path to find
335
- # @param type [nil,:file,:directory] Type of file system object to find,
336
- # or nil to return any type.
337
- #
338
- # @return [String] Absolute path of the result
339
- # @return [nil] if the data was not found.
340
- #
341
- def find_data(path, type: nil)
342
- # Source available in the toys-core gem
343
- end
344
- alias __find_data find_data
345
-
346
- ##
347
- # Exit immediately with the given status code.
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
- #
352
- # @param code [Integer] The status code, which should be 0 for no error,
353
- # or nonzero for an error condition. Default is 0.
354
- # @return [void]
355
- #
356
- def exit(code = 0)
357
- # Source available in the toys-core gem
358
- end
359
- alias __exit exit
360
-
361
- ##
362
- # Exit immediately with the given status code. This class method can be
363
- # called if the instance method is or could be replaced by the tool.
364
- #
365
- # @param code [Integer] The status code, which should be 0 for no error,
366
- # or nonzero for an error condition. Default is 0.
367
- # @return [void]
368
- #
369
- def self.exit(code = 0)
370
- # Source available in the toys-core gem
371
- end
372
-
373
- ##
374
- # Create a Context object. Applications generally will not need to create
375
- # these objects directly; they are created by the tool when it is preparing
376
- # for execution.
377
- #
378
- # @param data [Hash]
379
- #
380
- # @private This interface is internal and subject to change without warning.
381
- #
382
- def initialize(data)
383
- # Source available in the toys-core gem
384
- end
385
- end
386
- end
@@ -1,14 +0,0 @@
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.15.6"
13
- end
14
- end
@@ -1,56 +0,0 @@
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