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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +2 -2
- data/builtins/system/tools.rb +1 -1
- data/lib/toys/templates/clean.rb +1 -1
- data/lib/toys/templates/gem_build.rb +1 -1
- data/lib/toys/templates/rubocop.rb +4 -1
- data/lib/toys/version.rb +1 -1
- metadata +8 -63
- data/core-docs/toys/acceptor.rb +0 -474
- data/core-docs/toys/arg_parser.rb +0 -397
- data/core-docs/toys/cli.rb +0 -466
- data/core-docs/toys/compat.rb +0 -2
- data/core-docs/toys/completion.rb +0 -340
- data/core-docs/toys/context.rb +0 -386
- data/core-docs/toys/core.rb +0 -14
- data/core-docs/toys/dsl/base.rb +0 -56
- data/core-docs/toys/dsl/flag.rb +0 -284
- data/core-docs/toys/dsl/flag_group.rb +0 -267
- data/core-docs/toys/dsl/internal.rb +0 -4
- data/core-docs/toys/dsl/positional_arg.rb +0 -155
- data/core-docs/toys/dsl/tool.rb +0 -1639
- data/core-docs/toys/errors.rb +0 -126
- data/core-docs/toys/flag.rb +0 -560
- data/core-docs/toys/flag_group.rb +0 -186
- data/core-docs/toys/input_file.rb +0 -17
- data/core-docs/toys/loader.rb +0 -363
- data/core-docs/toys/middleware.rb +0 -336
- data/core-docs/toys/mixin.rb +0 -142
- data/core-docs/toys/module_lookup.rb +0 -75
- data/core-docs/toys/positional_arg.rb +0 -145
- data/core-docs/toys/settings.rb +0 -524
- data/core-docs/toys/source_info.rb +0 -271
- data/core-docs/toys/standard_middleware/add_verbosity_flags.rb +0 -49
- data/core-docs/toys/standard_middleware/apply_config.rb +0 -24
- data/core-docs/toys/standard_middleware/handle_usage_errors.rb +0 -33
- data/core-docs/toys/standard_middleware/set_default_descriptions.rb +0 -222
- data/core-docs/toys/standard_middleware/show_help.rb +0 -190
- data/core-docs/toys/standard_middleware/show_root_version.rb +0 -45
- data/core-docs/toys/standard_mixins/bundler.rb +0 -98
- data/core-docs/toys/standard_mixins/exec.rb +0 -711
- data/core-docs/toys/standard_mixins/fileutils.rb +0 -18
- data/core-docs/toys/standard_mixins/gems.rb +0 -62
- data/core-docs/toys/standard_mixins/git_cache.rb +0 -41
- data/core-docs/toys/standard_mixins/highline.rb +0 -133
- data/core-docs/toys/standard_mixins/pager.rb +0 -50
- data/core-docs/toys/standard_mixins/terminal.rb +0 -135
- data/core-docs/toys/standard_mixins/xdg.rb +0 -49
- data/core-docs/toys/template.rb +0 -112
- data/core-docs/toys/tool_definition.rb +0 -1079
- data/core-docs/toys/utils/completion_engine.rb +0 -49
- data/core-docs/toys/utils/exec.rb +0 -776
- data/core-docs/toys/utils/gems.rb +0 -185
- data/core-docs/toys/utils/git_cache.rb +0 -353
- data/core-docs/toys/utils/help_text.rb +0 -134
- data/core-docs/toys/utils/pager.rb +0 -118
- data/core-docs/toys/utils/standard_ui.rb +0 -184
- data/core-docs/toys/utils/terminal.rb +0 -310
- data/core-docs/toys/utils/xdg.rb +0 -253
- data/core-docs/toys/wrappable_string.rb +0 -132
- data/core-docs/toys-core.rb +0 -111
|
@@ -1,340 +0,0 @@
|
|
|
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
|