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,340 @@
1
+ module Toys
2
+ ##
3
+ # **_Defined in the toys-core gem_**
4
+ #
5
+ # A Completion is a callable Proc that determines candidates for shell tab
6
+ # completion. You pass a {Toys::Completion::Context} object (which includes
7
+ # the current string fragment and other information) and it returns an array
8
+ # of candidates, represented by {Toys::Completion::Candidate} objects, for
9
+ # completing the fragment.
10
+ #
11
+ # A useful method here is the class method {Toys::Completion.create} which
12
+ # takes a variety of inputs and returns a suitable completion Proc.
13
+ #
14
+ module Completion
15
+ ##
16
+ # **_Defined in the toys-core gem_**
17
+ #
18
+ # The context in which to determine completion candidates.
19
+ #
20
+ class Context
21
+ ##
22
+ # Create a completion context
23
+ #
24
+ # @param cli [Toys::CLI] The CLI being run. Required.
25
+ # @param previous_words [Array<String>] Array of complete strings that
26
+ # appeared prior to the fragment to complete.
27
+ # @param fragment_prefix [String] A prefix in the fragment that does not
28
+ # participate in completion. (e.g. "key=")
29
+ # @param fragment [String] The string fragment to complete.
30
+ # @param params [Hash] Miscellaneous context data
31
+ #
32
+ def initialize(cli:, previous_words: [], fragment_prefix: "", fragment: "", **params)
33
+ # Source available in the toys-core gem
34
+ end
35
+
36
+ ##
37
+ # Create a new completion context with the given modifications.
38
+ #
39
+ # @param delta_params [Hash] Replace context data.
40
+ # @return [Toys::Completion::Context]
41
+ #
42
+ def with(**delta_params)
43
+ # Source available in the toys-core gem
44
+ end
45
+
46
+ ##
47
+ # The CLI being run.
48
+ # @return [Toys::CLI]
49
+ #
50
+ attr_reader :cli
51
+
52
+ ##
53
+ # All previous words.
54
+ # @return [Array<String>]
55
+ #
56
+ attr_reader :previous_words
57
+
58
+ ##
59
+ # A non-completed prefix for the current fragment.
60
+ # @return [String]
61
+ #
62
+ attr_reader :fragment_prefix
63
+
64
+ ##
65
+ # The current string fragment to complete
66
+ # @return [String]
67
+ #
68
+ attr_reader :fragment
69
+
70
+ ##
71
+ # Get data for arbitrary key.
72
+ # @param [Symbol] key
73
+ # @return [Object]
74
+ #
75
+ def [](key)
76
+ # Source available in the toys-core gem
77
+ end
78
+ alias get []
79
+
80
+ ##
81
+ # The tool being invoked, which should control the completion.
82
+ # @return [Toys::ToolDefinition]
83
+ #
84
+ def tool
85
+ # Source available in the toys-core gem
86
+ end
87
+
88
+ ##
89
+ # An array of complete arguments passed to the tool, prior to the
90
+ # fragment to complete.
91
+ # @return [Array<String>]
92
+ #
93
+ def args
94
+ # Source available in the toys-core gem
95
+ end
96
+
97
+ ##
98
+ # Current ArgParser indicating the status of argument parsing up to
99
+ # this point.
100
+ #
101
+ # @return [Toys::ArgParser]
102
+ #
103
+ def arg_parser
104
+ # Source available in the toys-core gem
105
+ end
106
+ end
107
+
108
+ ##
109
+ # **_Defined in the toys-core gem_**
110
+ #
111
+ # A candidate for completing a string fragment.
112
+ #
113
+ # A candidate includes a string representing the potential completed
114
+ # word, as well as a flag indicating whether it is a *partial* completion
115
+ # (i.e. a prefix that could still be added to) versus a *final* word.
116
+ # Generally, tab completion systems should add a trailing space after a
117
+ # final completion but not after a partial completion.
118
+ #
119
+ class Candidate
120
+ include ::Comparable
121
+
122
+ ##
123
+ # Create a new candidate
124
+ # @param string [String] The candidate string
125
+ # @param partial [Boolean] Whether the candidate is partial. Defaults
126
+ # to `false`.
127
+ #
128
+ def initialize(string, partial: false)
129
+ # Source available in the toys-core gem
130
+ end
131
+
132
+ ##
133
+ # Get the candidate string.
134
+ # @return [String]
135
+ #
136
+ attr_reader :string
137
+ alias to_s string
138
+
139
+ ##
140
+ # Determine whether the candidate is partial completion.
141
+ # @return [Boolean]
142
+ #
143
+ def partial?
144
+ # Source available in the toys-core gem
145
+ end
146
+
147
+ ##
148
+ # Determine whether the candidate is a final completion.
149
+ # @return [Boolean]
150
+ #
151
+ def final?
152
+ # Source available in the toys-core gem
153
+ end
154
+
155
+ ##
156
+ # Create an array of candidates given an array of strings.
157
+ #
158
+ # @param array [Array<String>]
159
+ # @return [Array<Toys::Completion::Candidate]
160
+ #
161
+ def self.new_multi(array, partial: false)
162
+ # Source available in the toys-core gem
163
+ end
164
+ end
165
+
166
+ ##
167
+ # **_Defined in the toys-core gem_**
168
+ #
169
+ # A base class that returns no completions.
170
+ #
171
+ # Completions *may* but do not need to subclass this base class. They
172
+ # merely need to duck-type `Proc` by implementing the `call` method.
173
+ #
174
+ class Base
175
+ ##
176
+ # Returns candidates for the current completion.
177
+ # This default implementation returns an empty list.
178
+ #
179
+ # @param context [Toys::Completion::Context] The current completion
180
+ # context including the string fragment.
181
+ # @return [Array<Toys::Completion::Candidate>] An array of candidates
182
+ #
183
+ def call(context)
184
+ # Source available in the toys-core gem
185
+ end
186
+ end
187
+
188
+ ##
189
+ # **_Defined in the toys-core gem_**
190
+ #
191
+ # A Completion that returns candidates from the local file system.
192
+ #
193
+ class FileSystem < Base
194
+ ##
195
+ # Create a completion that gets candidates from names in the local file
196
+ # system.
197
+ #
198
+ # @param cwd [String] Working directory (defaults to the current dir).
199
+ # @param omit_files [Boolean] Omit files from candidates
200
+ # @param omit_directories [Boolean] Omit directories from candidates
201
+ # @param prefix_constraint [String,Regexp] Constraint on the fragment
202
+ # prefix. Defaults to requiring the prefix be empty.
203
+ #
204
+ def initialize(cwd: nil, omit_files: false, omit_directories: false, prefix_constraint: "")
205
+ # Source available in the toys-core gem
206
+ end
207
+
208
+ ##
209
+ # Whether files are included in the completion candidates.
210
+ # @return [Boolean]
211
+ #
212
+ attr_reader :include_files
213
+
214
+ ##
215
+ # Whether directories are included in the completion candidates.
216
+ # @return [Boolean]
217
+ #
218
+ attr_reader :include_directories
219
+
220
+ ##
221
+ # Constraint on the fragment prefix.
222
+ # @return [String,Regexp]
223
+ #
224
+ attr_reader :prefix_constraint
225
+
226
+ ##
227
+ # Path to the starting directory.
228
+ # @return [String]
229
+ #
230
+ attr_reader :cwd
231
+
232
+ ##
233
+ # Returns candidates for the current completion.
234
+ #
235
+ # @param context [Toys::Completion::Context] the current completion
236
+ # context including the string fragment.
237
+ # @return [Array<Toys::Completion::Candidate>] an array of candidates
238
+ #
239
+ def call(context)
240
+ # Source available in the toys-core gem
241
+ end
242
+ end
243
+
244
+ ##
245
+ # **_Defined in the toys-core gem_**
246
+ #
247
+ # A Completion whose candidates come from a static list of strings.
248
+ #
249
+ class Enum < Base
250
+ ##
251
+ # Create a completion from a list of values.
252
+ #
253
+ # @param values [Array<String>]
254
+ # @param prefix_constraint [String,Regexp] Constraint on the fragment
255
+ # prefix. Defaults to requiring the prefix be empty.
256
+ #
257
+ def initialize(values, prefix_constraint: "")
258
+ # Source available in the toys-core gem
259
+ end
260
+
261
+ ##
262
+ # The array of completion candidates.
263
+ # @return [Array<String>]
264
+ #
265
+ attr_reader :values
266
+
267
+ ##
268
+ # Constraint on the fragment prefix.
269
+ # @return [String,Regexp]
270
+ #
271
+ attr_reader :prefix_constraint
272
+
273
+ ##
274
+ # Returns candidates for the current completion.
275
+ #
276
+ # @param context [Toys::Completion::Context] the current completion
277
+ # context including the string fragment.
278
+ # @return [Array<Toys::Completion::Candidate>] an array of candidates
279
+ #
280
+ def call(context)
281
+ # Source available in the toys-core gem
282
+ end
283
+ end
284
+
285
+ ##
286
+ # An instance of the empty completion that returns no candidates.
287
+ # @return [Toys:::Completion::Base]
288
+ #
289
+ EMPTY = Base.new
290
+
291
+ ##
292
+ # Create a completion Proc from a variety of specification formats. The
293
+ # completion is constructed from the given specification object and/or the
294
+ # given block. Additionally, some completions can take a hash of options.
295
+ #
296
+ # Recognized specs include:
297
+ #
298
+ # * `:empty`: Returns the empty completion. Any block or options are
299
+ # ignored.
300
+ #
301
+ # * `:file_system`: Returns a completion that searches the current
302
+ # directory for file and directory names. You may also pass any of the
303
+ # options recognized by {Toys::Completion::FileSystem#initialize}. The
304
+ # block is ignored.
305
+ #
306
+ # * An **Array** of strings. Returns a completion that uses those values
307
+ # as candidates. You may also pass any of the options recognized by
308
+ # {Toys::Completion::Enum#initialize}. The block is ignored.
309
+ #
310
+ # * A **function**, either passed as a Proc (where the block is ignored)
311
+ # or as a block (if the spec is nil). The function must behave as a
312
+ # completion object, taking {Toys::Completion::Context} as the sole
313
+ # argument, and returning an array of {Toys::Completion::Candidate}.
314
+ #
315
+ # * `:default` and `nil` indicate the **default completion**. For this
316
+ # method, the default is the empty completion (i.e. these are synonyms
317
+ # for `:empty`). However, other completion resolution methods might
318
+ # have a different default.
319
+ #
320
+ # @param spec [Object] See the description for recognized values.
321
+ # @param options [Hash] Additional options to pass to the completion.
322
+ # @param block [Proc] See the description for recognized forms.
323
+ # @return [Toys::Completion::Base,Proc]
324
+ #
325
+ def self.create(spec = nil, **options, &block)
326
+ # Source available in the toys-core gem
327
+ end
328
+
329
+ ##
330
+ # Take the various ways to express a completion spec, and convert them to a
331
+ # canonical form expressed as a single object. This is called from the DSL
332
+ # DSL to generate a spec object that can be stored.
333
+ #
334
+ # @private This interface is internal and subject to change without warning.
335
+ #
336
+ def self.scalarize_spec(spec, options, block)
337
+ # Source available in the toys-core gem
338
+ end
339
+ end
340
+ end
@@ -0,0 +1,386 @@
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