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,271 +0,0 @@
|
|
|
1
|
-
module Toys
|
|
2
|
-
##
|
|
3
|
-
# **_Defined in the toys-core gem_**
|
|
4
|
-
#
|
|
5
|
-
# Information about the source of a tool, such as the file, git repository,
|
|
6
|
-
# or block that defined it.
|
|
7
|
-
#
|
|
8
|
-
# This object represents a source of tool information and definitions. Such a
|
|
9
|
-
# source could include:
|
|
10
|
-
#
|
|
11
|
-
# * A toys directory
|
|
12
|
-
# * A single toys file
|
|
13
|
-
# * A file or directory loaded from git
|
|
14
|
-
# * A config block passed directly to the CLI
|
|
15
|
-
# * A tool block within a toys file
|
|
16
|
-
#
|
|
17
|
-
# The SourceInfo provides information such as the tool's context directory,
|
|
18
|
-
# and locates data and lib directories appropriate to the tool. It also
|
|
19
|
-
# locates the tool's source code so it can be reported when an error occurs.
|
|
20
|
-
#
|
|
21
|
-
# Each tool has a unique SourceInfo with all the information specific to that
|
|
22
|
-
# tool. Additionally, SourceInfo objects are arranged in a containment
|
|
23
|
-
# hierarchy. For example, a SourceInfo object representing a toys files could
|
|
24
|
-
# have a parent representing a toys directory, and an object representing a
|
|
25
|
-
# tool block could have a parent representing an enclosing block or a file.
|
|
26
|
-
#
|
|
27
|
-
# Child SourceInfo objects generally inherit some attributes of their parent.
|
|
28
|
-
# For example, the `.toys` directory in a project directory defines the
|
|
29
|
-
# context directory as that project directory. Then all tools defined under
|
|
30
|
-
# that directory will share that context directory, so all SourceInfo objects
|
|
31
|
-
# descending from that root will inherit that value (unless it's changed
|
|
32
|
-
# explicitly).
|
|
33
|
-
#
|
|
34
|
-
# SourceInfo objects can be obtained in the DSL from
|
|
35
|
-
# {Toys::DSL::Tool#source_info} or at runtime by getting the
|
|
36
|
-
# {Toys::Context::Key::TOOL_SOURCE} key. However, they are created internally
|
|
37
|
-
# by the Loader and should not be created manually.
|
|
38
|
-
#
|
|
39
|
-
class SourceInfo
|
|
40
|
-
##
|
|
41
|
-
# The parent of this SourceInfo.
|
|
42
|
-
#
|
|
43
|
-
# @return [Toys::SourceInfo] The parent.
|
|
44
|
-
# @return [nil] if this SourceInfo is a root.
|
|
45
|
-
#
|
|
46
|
-
attr_reader :parent
|
|
47
|
-
|
|
48
|
-
##
|
|
49
|
-
# The root ancestor of this SourceInfo. This generally represents a source
|
|
50
|
-
# that was added directly to a CLI in code.
|
|
51
|
-
#
|
|
52
|
-
# @return [Toys::SourceInfo] The root ancestor.
|
|
53
|
-
#
|
|
54
|
-
attr_reader :root
|
|
55
|
-
|
|
56
|
-
##
|
|
57
|
-
# The priority of tools defined by this source. Higher values indicate a
|
|
58
|
-
# higher priority. Lower priority values could be negative.
|
|
59
|
-
#
|
|
60
|
-
# @return [Integer] The priority.
|
|
61
|
-
#
|
|
62
|
-
attr_reader :priority
|
|
63
|
-
|
|
64
|
-
##
|
|
65
|
-
# The context directory path (normally the directory containing the
|
|
66
|
-
# toplevel toys file or directory).
|
|
67
|
-
#
|
|
68
|
-
# This is not affected by setting a custom context directory for a tool.
|
|
69
|
-
#
|
|
70
|
-
# @return [String] The context directory path.
|
|
71
|
-
# @return [nil] if there is no context directory (perhaps because the root
|
|
72
|
-
# source was a block)
|
|
73
|
-
#
|
|
74
|
-
attr_reader :context_directory
|
|
75
|
-
|
|
76
|
-
##
|
|
77
|
-
# The source, which may be a path or a proc depending on the {#source_type}.
|
|
78
|
-
#
|
|
79
|
-
# @return [String] Path to the source file or directory.
|
|
80
|
-
# @return [Proc] The block serving as the source.
|
|
81
|
-
#
|
|
82
|
-
attr_reader :source
|
|
83
|
-
|
|
84
|
-
##
|
|
85
|
-
# The type of source. This could be:
|
|
86
|
-
#
|
|
87
|
-
# * `:file`, representing a single toys file. The {#source} will be the
|
|
88
|
-
# filesystem path to that file.
|
|
89
|
-
# * `:directory`, representing a toys directory. The {#source} will be the
|
|
90
|
-
# filesystem path to that directory.
|
|
91
|
-
# * `:proc`, representing a proc, which could be a toplevel block added
|
|
92
|
-
# directly to a CLI, a `tool` block within a toys file, or a block within
|
|
93
|
-
# another block. The {#source} will be the proc itself.
|
|
94
|
-
#
|
|
95
|
-
# @return [:file,:directory,:proc]
|
|
96
|
-
#
|
|
97
|
-
attr_reader :source_type
|
|
98
|
-
|
|
99
|
-
##
|
|
100
|
-
# The path of the current source file or directory.
|
|
101
|
-
#
|
|
102
|
-
# This could be set even if {#source_type} is `:proc`, if that proc is
|
|
103
|
-
# defined within a toys file. The only time this is not set is if the
|
|
104
|
-
# source is added directly to a CLI in a code block.
|
|
105
|
-
#
|
|
106
|
-
# @return [String] The source path
|
|
107
|
-
# @return [nil] if this source has no file system path.
|
|
108
|
-
#
|
|
109
|
-
attr_reader :source_path
|
|
110
|
-
|
|
111
|
-
##
|
|
112
|
-
# The source proc. This is set if {#source_type} is `:proc`.
|
|
113
|
-
#
|
|
114
|
-
# @return [Proc] The source proc
|
|
115
|
-
# @return [nil] if this source has no proc.
|
|
116
|
-
#
|
|
117
|
-
attr_reader :source_proc
|
|
118
|
-
|
|
119
|
-
##
|
|
120
|
-
# The git remote. This is set if the source, or one of its ancestors, comes
|
|
121
|
-
# from git.
|
|
122
|
-
#
|
|
123
|
-
# @return [String] The git remote
|
|
124
|
-
# @return [nil] if this source is not fron git.
|
|
125
|
-
#
|
|
126
|
-
attr_reader :git_remote
|
|
127
|
-
|
|
128
|
-
##
|
|
129
|
-
# The git path. This is set if the source, or one of its ancestors, comes
|
|
130
|
-
# from git.
|
|
131
|
-
#
|
|
132
|
-
# @return [String] The git path. This could be the empty string.
|
|
133
|
-
# @return [nil] if this source is not fron git.
|
|
134
|
-
#
|
|
135
|
-
attr_reader :git_path
|
|
136
|
-
|
|
137
|
-
##
|
|
138
|
-
# The git commit. This is set if the source, or one of its ancestors, comes
|
|
139
|
-
# from git.
|
|
140
|
-
#
|
|
141
|
-
# @return [String] The git commit.
|
|
142
|
-
# @return [nil] if this source is not fron git.
|
|
143
|
-
#
|
|
144
|
-
attr_reader :git_commit
|
|
145
|
-
|
|
146
|
-
##
|
|
147
|
-
# A user-visible name of this source.
|
|
148
|
-
#
|
|
149
|
-
# @return [String]
|
|
150
|
-
#
|
|
151
|
-
attr_reader :source_name
|
|
152
|
-
alias to_s source_name
|
|
153
|
-
|
|
154
|
-
##
|
|
155
|
-
# Locate the given data file or directory and return an absolute path.
|
|
156
|
-
#
|
|
157
|
-
# @param path [String] The relative path to find
|
|
158
|
-
# @param type [nil,:file,:directory] Type of file system object to find,
|
|
159
|
-
# or nil (the default) to return any type.
|
|
160
|
-
# @return [String] Absolute path of the resulting data.
|
|
161
|
-
# @return [nil] if the data was not found.
|
|
162
|
-
#
|
|
163
|
-
def find_data(path, type: nil)
|
|
164
|
-
# Source available in the toys-core gem
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
##
|
|
168
|
-
# Apply all lib paths in order from high to low priority
|
|
169
|
-
#
|
|
170
|
-
# @return [self]
|
|
171
|
-
#
|
|
172
|
-
def apply_lib_paths
|
|
173
|
-
# Source available in the toys-core gem
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
##
|
|
177
|
-
# Create a SourceInfo.
|
|
178
|
-
#
|
|
179
|
-
# @private This interface is internal and subject to change without warning.
|
|
180
|
-
#
|
|
181
|
-
def initialize(parent, priority, context_directory, source_type, source_path, source_proc,
|
|
182
|
-
git_remote, git_path, git_commit, source_name, data_dir_name, lib_dir_name)
|
|
183
|
-
# Source available in the toys-core gem
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
##
|
|
187
|
-
# Create a child SourceInfo relative to the parent path.
|
|
188
|
-
#
|
|
189
|
-
# @private This interface is internal and subject to change without warning.
|
|
190
|
-
#
|
|
191
|
-
def relative_child(filename, source_name: nil)
|
|
192
|
-
# Source available in the toys-core gem
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
##
|
|
196
|
-
# Create a child SourceInfo with an absolute path.
|
|
197
|
-
#
|
|
198
|
-
# @private This interface is internal and subject to change without warning.
|
|
199
|
-
#
|
|
200
|
-
def absolute_child(child_path, source_name: nil)
|
|
201
|
-
# Source available in the toys-core gem
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
##
|
|
205
|
-
# Create a child SourceInfo with a git source.
|
|
206
|
-
#
|
|
207
|
-
# @private This interface is internal and subject to change without warning.
|
|
208
|
-
#
|
|
209
|
-
def git_child(child_git_remote, child_git_path, child_git_commit, child_path,
|
|
210
|
-
source_name: nil)
|
|
211
|
-
# Source available in the toys-core gem
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
##
|
|
215
|
-
# Create a proc child SourceInfo
|
|
216
|
-
#
|
|
217
|
-
# @private This interface is internal and subject to change without warning.
|
|
218
|
-
#
|
|
219
|
-
def proc_child(child_proc, source_name: nil)
|
|
220
|
-
# Source available in the toys-core gem
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
##
|
|
224
|
-
# Create a root source info for a file path.
|
|
225
|
-
#
|
|
226
|
-
# @private This interface is internal and subject to change without warning.
|
|
227
|
-
#
|
|
228
|
-
def self.create_path_root(source_path, priority,
|
|
229
|
-
context_directory: nil,
|
|
230
|
-
data_dir_name: nil,
|
|
231
|
-
lib_dir_name: nil,
|
|
232
|
-
source_name: nil)
|
|
233
|
-
# Source available in the toys-core gem
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
##
|
|
237
|
-
# Create a root source info for a cached git repo.
|
|
238
|
-
#
|
|
239
|
-
# @private This interface is internal and subject to change without warning.
|
|
240
|
-
#
|
|
241
|
-
def self.create_git_root(git_remote, git_path, git_commit, source_path, priority,
|
|
242
|
-
context_directory: nil,
|
|
243
|
-
data_dir_name: nil,
|
|
244
|
-
lib_dir_name: nil,
|
|
245
|
-
source_name: nil)
|
|
246
|
-
# Source available in the toys-core gem
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
##
|
|
250
|
-
# Create a root source info for a proc.
|
|
251
|
-
#
|
|
252
|
-
# @private This interface is internal and subject to change without warning.
|
|
253
|
-
#
|
|
254
|
-
def self.create_proc_root(source_proc, priority,
|
|
255
|
-
context_directory: nil,
|
|
256
|
-
data_dir_name: nil,
|
|
257
|
-
lib_dir_name: nil,
|
|
258
|
-
source_name: nil)
|
|
259
|
-
# Source available in the toys-core gem
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
##
|
|
263
|
-
# Check a path and determine the canonical path and type.
|
|
264
|
-
#
|
|
265
|
-
# @private This interface is internal and subject to change without warning.
|
|
266
|
-
#
|
|
267
|
-
def self.check_path(path, lenient)
|
|
268
|
-
# Source available in the toys-core gem
|
|
269
|
-
end
|
|
270
|
-
end
|
|
271
|
-
end
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
module Toys
|
|
2
|
-
module StandardMiddleware
|
|
3
|
-
##
|
|
4
|
-
# **_Defined in the toys-core gem_**
|
|
5
|
-
#
|
|
6
|
-
# A middleware that provides flags for editing the verbosity.
|
|
7
|
-
#
|
|
8
|
-
# This middleware adds `-v`, `--verbose`, `-q`, and `--quiet` flags, if
|
|
9
|
-
# not already defined by the tool. These flags affect the setting of
|
|
10
|
-
# {Toys::Context::Key::VERBOSITY}, and, thus, the logger level.
|
|
11
|
-
#
|
|
12
|
-
class AddVerbosityFlags
|
|
13
|
-
##
|
|
14
|
-
# Default verbose flags
|
|
15
|
-
# @return [Array<String>]
|
|
16
|
-
#
|
|
17
|
-
DEFAULT_VERBOSE_FLAGS = ["-v", "--verbose"].freeze
|
|
18
|
-
|
|
19
|
-
##
|
|
20
|
-
# Default quiet flags
|
|
21
|
-
# @return [Array<String>]
|
|
22
|
-
#
|
|
23
|
-
DEFAULT_QUIET_FLAGS = ["-q", "--quiet"].freeze
|
|
24
|
-
|
|
25
|
-
##
|
|
26
|
-
# Create a AddVerbosityFlags middleware.
|
|
27
|
-
#
|
|
28
|
-
# @param verbose_flags [Boolean,Array<String>,Proc] Specify flags
|
|
29
|
-
# to increase verbosity. The value may be any of the following:
|
|
30
|
-
#
|
|
31
|
-
# * An array of flags that increase verbosity.
|
|
32
|
-
# * The `true` value to use {DEFAULT_VERBOSE_FLAGS}. (Default)
|
|
33
|
-
# * The `false` value to disable verbose flags.
|
|
34
|
-
# * A proc that takes a tool and returns any of the above.
|
|
35
|
-
#
|
|
36
|
-
# @param quiet_flags [Boolean,Array<String>,Proc] Specify flags
|
|
37
|
-
# to decrease verbosity. The value may be any of the following:
|
|
38
|
-
#
|
|
39
|
-
# * An array of flags that decrease verbosity.
|
|
40
|
-
# * The `true` value to use {DEFAULT_QUIET_FLAGS}. (Default)
|
|
41
|
-
# * The `false` value to disable quiet flags.
|
|
42
|
-
# * A proc that takes a tool and returns any of the above.
|
|
43
|
-
#
|
|
44
|
-
def initialize(verbose_flags: true, quiet_flags: true)
|
|
45
|
-
# Source available in the toys-core gem
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module Toys
|
|
2
|
-
module StandardMiddleware
|
|
3
|
-
##
|
|
4
|
-
# **_Defined in the toys-core gem_**
|
|
5
|
-
#
|
|
6
|
-
# A middleware that applies the given block to all tool configurations.
|
|
7
|
-
#
|
|
8
|
-
class ApplyConfig
|
|
9
|
-
##
|
|
10
|
-
# Create an ApplyConfig middleware
|
|
11
|
-
#
|
|
12
|
-
# @param parent_source [Toys::SourceInfo] The SourceInfo corresponding to
|
|
13
|
-
# the source where this block is provided, or `nil` (the default) if
|
|
14
|
-
# the block does not come from a Toys file.
|
|
15
|
-
# @param source_name [String] A user-visible name for the source, or
|
|
16
|
-
# `nil` to use the default.
|
|
17
|
-
# @param block [Proc] The configuration to apply.
|
|
18
|
-
#
|
|
19
|
-
def initialize(parent_source: nil, source_name: nil, &block)
|
|
20
|
-
# Source available in the toys-core gem
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
module Toys
|
|
2
|
-
module StandardMiddleware
|
|
3
|
-
##
|
|
4
|
-
# **_Defined in the toys-core gem_**
|
|
5
|
-
#
|
|
6
|
-
# This middleware handles the case of a usage error. If a usage error, such
|
|
7
|
-
# as an unrecognized flag or an unfulfilled required argument, is detected,
|
|
8
|
-
# this middleware intercepts execution and displays the error along with
|
|
9
|
-
# the short help string, and terminates execution with an error code.
|
|
10
|
-
#
|
|
11
|
-
class HandleUsageErrors
|
|
12
|
-
##
|
|
13
|
-
# Exit code for usage error. (2 by convention)
|
|
14
|
-
# @return [Integer]
|
|
15
|
-
#
|
|
16
|
-
USAGE_ERROR_EXIT_CODE = 2
|
|
17
|
-
|
|
18
|
-
##
|
|
19
|
-
# Create a HandleUsageErrors middleware.
|
|
20
|
-
#
|
|
21
|
-
# @param exit_code [Integer] The exit code to return if a usage error
|
|
22
|
-
# occurs. Default is {USAGE_ERROR_EXIT_CODE}.
|
|
23
|
-
# @param stream [IO] Output stream to write to. Default is stderr.
|
|
24
|
-
# @param styled_output [Boolean,nil] Cause the tool to display help text
|
|
25
|
-
# with ansi styles. If `nil`, display styles if the output stream is
|
|
26
|
-
# a tty. Default is `nil`.
|
|
27
|
-
#
|
|
28
|
-
def initialize(exit_code: nil, stream: $stderr, styled_output: nil)
|
|
29
|
-
# Source available in the toys-core gem
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
module Toys
|
|
2
|
-
module StandardMiddleware
|
|
3
|
-
##
|
|
4
|
-
# **_Defined in the toys-core gem_**
|
|
5
|
-
#
|
|
6
|
-
# This middleware sets default description fields for tools and command
|
|
7
|
-
# line arguments and flags that do not have them set otherwise.
|
|
8
|
-
#
|
|
9
|
-
# You can modify the static descriptions for tools, namespaces, and the
|
|
10
|
-
# root tool by passing parameters to this middleware. For finer control,
|
|
11
|
-
# you can override methods to modify the description generation logic.
|
|
12
|
-
#
|
|
13
|
-
class SetDefaultDescriptions
|
|
14
|
-
##
|
|
15
|
-
# The default description for tools.
|
|
16
|
-
# @return [String]
|
|
17
|
-
#
|
|
18
|
-
DEFAULT_TOOL_DESC = "(No tool description available)"
|
|
19
|
-
|
|
20
|
-
##
|
|
21
|
-
# The default description for delegating tools.
|
|
22
|
-
# @return [String]
|
|
23
|
-
#
|
|
24
|
-
DEFAULT_DELEGATE_DESC = '(Delegates to "%<target>s")'
|
|
25
|
-
|
|
26
|
-
##
|
|
27
|
-
# The default description for namespaces.
|
|
28
|
-
# @return [String]
|
|
29
|
-
#
|
|
30
|
-
DEFAULT_NAMESPACE_DESC = "(A namespace of tools)"
|
|
31
|
-
|
|
32
|
-
##
|
|
33
|
-
# The default description for the root tool.
|
|
34
|
-
# @return [String]
|
|
35
|
-
#
|
|
36
|
-
DEFAULT_ROOT_DESC = "Command line tool built using the toys-core gem."
|
|
37
|
-
|
|
38
|
-
##
|
|
39
|
-
# The default long description for the root tool.
|
|
40
|
-
# @return [String]
|
|
41
|
-
#
|
|
42
|
-
DEFAULT_ROOT_LONG_DESC = [
|
|
43
|
-
"This command line tool was built using the toys-core gem. See" \
|
|
44
|
-
" https://dazuma.github.io/toys/gems/toys-core for more info.",
|
|
45
|
-
"To replace this message, set the description and long description" \
|
|
46
|
-
" of the root tool, or configure the SetDefaultDescriptions" \
|
|
47
|
-
" middleware.",
|
|
48
|
-
].freeze
|
|
49
|
-
|
|
50
|
-
##
|
|
51
|
-
# Create a SetDefaultDescriptions middleware given default descriptions.
|
|
52
|
-
#
|
|
53
|
-
# @param default_tool_desc [String,nil] The default short description for
|
|
54
|
-
# runnable tools, or `nil` not to set one. Defaults to
|
|
55
|
-
# {DEFAULT_TOOL_DESC}.
|
|
56
|
-
# @param default_tool_long_desc [Array<String>,nil] The default long
|
|
57
|
-
# description for runnable tools, or `nil` not to set one. Defaults
|
|
58
|
-
# to `nil`.
|
|
59
|
-
# @param default_namespace_desc [String,nil] The default short
|
|
60
|
-
# description for non-runnable tools, or `nil` not to set one.
|
|
61
|
-
# Defaults to {DEFAULT_TOOL_DESC}.
|
|
62
|
-
# @param default_namespace_long_desc [Array<String>,nil] The default long
|
|
63
|
-
# description for non-runnable tools, or `nil` not to set one.
|
|
64
|
-
# Defaults to `nil`.
|
|
65
|
-
# @param default_root_desc [String,nil] The default short description for
|
|
66
|
-
# the root tool, or `nil` not to set one. Defaults to
|
|
67
|
-
# {DEFAULT_ROOT_DESC}.
|
|
68
|
-
# @param default_root_long_desc [Array<String>,nil] The default long
|
|
69
|
-
# description for the root tool, or `nil` not to set one. Defaults to
|
|
70
|
-
# {DEFAULT_ROOT_LONG_DESC}.
|
|
71
|
-
# @param default_delegate_desc [String,nil] The default short description
|
|
72
|
-
# for delegate tools, or `nil` not to set one. May include an sprintf
|
|
73
|
-
# field for the `target` name. Defaults to {DEFAULT_DELEGATE_DESC}.
|
|
74
|
-
#
|
|
75
|
-
def initialize(default_tool_desc: DEFAULT_TOOL_DESC,
|
|
76
|
-
default_tool_long_desc: nil,
|
|
77
|
-
default_namespace_desc: DEFAULT_NAMESPACE_DESC,
|
|
78
|
-
default_namespace_long_desc: nil,
|
|
79
|
-
default_root_desc: DEFAULT_ROOT_DESC,
|
|
80
|
-
default_root_long_desc: DEFAULT_ROOT_LONG_DESC,
|
|
81
|
-
default_delegate_desc: DEFAULT_DELEGATE_DESC)
|
|
82
|
-
# Source available in the toys-core gem
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
protected
|
|
86
|
-
|
|
87
|
-
##
|
|
88
|
-
# This method implements the logic for generating a tool description.
|
|
89
|
-
# By default, it uses the parameters given to the middleware object.
|
|
90
|
-
# Override this method to provide different logic.
|
|
91
|
-
#
|
|
92
|
-
# @param tool [Toys::ToolDefinition] The tool to document.
|
|
93
|
-
# @param data [Hash] Additional data that might be useful. Currently,
|
|
94
|
-
# the {Toys::Loader} is passed with key `:loader`. Future versions
|
|
95
|
-
# of Toys may provide additional information.
|
|
96
|
-
# @return [String,Array<String>,Toys::WrappableString] The default
|
|
97
|
-
# description. See {Toys::DSL::Tool#desc} for info on the format.
|
|
98
|
-
# @return [nil] if this middleware should not set the description.
|
|
99
|
-
#
|
|
100
|
-
def generate_tool_desc(tool, data)
|
|
101
|
-
# Source available in the toys-core gem
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
##
|
|
105
|
-
# This method implements logic for generating a tool long description.
|
|
106
|
-
# By default, it uses the parameters given to the middleware object.
|
|
107
|
-
# Override this method to provide different logic.
|
|
108
|
-
#
|
|
109
|
-
# @param tool [Toys::ToolDefinition] The tool to document
|
|
110
|
-
# @param data [Hash] Additional data that might be useful. Currently,
|
|
111
|
-
# the {Toys::Loader} is passed with key `:loader`. Future versions of
|
|
112
|
-
# Toys may provide additional information.
|
|
113
|
-
# @return [Array<Toys::WrappableString,String,Array<String>>] The default
|
|
114
|
-
# long description. See {Toys::DSL::Tool#long_desc} for info on the
|
|
115
|
-
# format.
|
|
116
|
-
# @return [nil] if this middleware should not set the long description.
|
|
117
|
-
#
|
|
118
|
-
def generate_tool_long_desc(tool, data)
|
|
119
|
-
# Source available in the toys-core gem
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
##
|
|
123
|
-
# This method implements the logic for generating a flag description.
|
|
124
|
-
# Override this method to provide different logic.
|
|
125
|
-
#
|
|
126
|
-
# @param flag [Toys::Flag] The flag to document
|
|
127
|
-
# @param data [Hash] Additional data that might be useful. Currently,
|
|
128
|
-
# the {Toys::ToolDefinition} is passed with key `:tool`. Future
|
|
129
|
-
# versions of Toys may provide additional information.
|
|
130
|
-
# @return [String,Array<String>,Toys::WrappableString] The default
|
|
131
|
-
# description. See {Toys::DSL::Tool#desc} for info on the format.
|
|
132
|
-
# @return [nil] if this middleware should not set the description.
|
|
133
|
-
#
|
|
134
|
-
def generate_flag_desc(flag, data)
|
|
135
|
-
# Source available in the toys-core gem
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
##
|
|
139
|
-
# This method implements logic for generating a flag long description.
|
|
140
|
-
# Override this method to provide different logic.
|
|
141
|
-
#
|
|
142
|
-
# @param flag [Toys::Flag] The flag to document
|
|
143
|
-
# @param data [Hash] Additional data that might be useful. Currently,
|
|
144
|
-
# the {Toys::ToolDefinition} is passed with key `:tool`. Future
|
|
145
|
-
# versions of Toys may provide additional information.
|
|
146
|
-
# @return [Array<Toys::WrappableString,String,Array<String>>] The default
|
|
147
|
-
# long description. See {Toys::DSL::Tool#long_desc} for info on the
|
|
148
|
-
# format.
|
|
149
|
-
# @return [nil] if this middleware should not set the long description.
|
|
150
|
-
#
|
|
151
|
-
def generate_flag_long_desc(flag, data)
|
|
152
|
-
# Source available in the toys-core gem
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
##
|
|
156
|
-
# This method implements the logic for generating an arg description.
|
|
157
|
-
# Override this method to provide different logic.
|
|
158
|
-
#
|
|
159
|
-
# @param arg [Toys::PositionalArg] The arg to document
|
|
160
|
-
# @param data [Hash] Additional data that might be useful. Currently,
|
|
161
|
-
# the {Toys::ToolDefinition} is passed with key `:tool`. Future
|
|
162
|
-
# versions of Toys may provide additional information.
|
|
163
|
-
# @return [String,Array<String>,Toys::WrappableString] The default
|
|
164
|
-
# description. See {Toys::DSL::Tool#desc} for info on the format.
|
|
165
|
-
# @return [nil] if this middleware should not set the description.
|
|
166
|
-
#
|
|
167
|
-
def generate_arg_desc(arg, data)
|
|
168
|
-
# Source available in the toys-core gem
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
##
|
|
172
|
-
# This method implements logic for generating an arg long description.
|
|
173
|
-
# Override this method to provide different logic.
|
|
174
|
-
#
|
|
175
|
-
# @param arg [Toys::PositionalArg] The arg to document
|
|
176
|
-
# @param data [Hash] Additional data that might be useful. Currently,
|
|
177
|
-
# the {Toys::ToolDefinition} is passed with key `:tool`. Future
|
|
178
|
-
# versions of Toys may provide additional information.
|
|
179
|
-
# @return [Array<Toys::WrappableString,String,Array<String>>] The default
|
|
180
|
-
# long description. See {Toys::DSL::Tool#long_desc} for info on the
|
|
181
|
-
# format.
|
|
182
|
-
# @return [nil] if this middleware should not set the long description.
|
|
183
|
-
#
|
|
184
|
-
def generate_arg_long_desc(arg, data)
|
|
185
|
-
# Source available in the toys-core gem
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
##
|
|
189
|
-
# This method implements the logic for generating a flag group
|
|
190
|
-
# description. Override this method to provide different logic.
|
|
191
|
-
#
|
|
192
|
-
# @param group [Toys::FlagGroup] The flag group to document
|
|
193
|
-
# @param data [Hash] Additional data that might be useful. Currently,
|
|
194
|
-
# the {Toys::ToolDefinition} is passed with key `:tool`. Future
|
|
195
|
-
# versions of Toys may provide additional information.
|
|
196
|
-
# @return [String,Array<String>,Toys::WrappableString] The default
|
|
197
|
-
# description. See {Toys::DSL::Tool#desc} for info on the format.
|
|
198
|
-
# @return [nil] if this middleware should not set the description.
|
|
199
|
-
#
|
|
200
|
-
def generate_flag_group_desc(group, data)
|
|
201
|
-
# Source available in the toys-core gem
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
##
|
|
205
|
-
# This method implements the logic for generating a flag group long
|
|
206
|
-
# description. Override this method to provide different logic.
|
|
207
|
-
#
|
|
208
|
-
# @param group [Toys::FlagGroup] The flag group to document
|
|
209
|
-
# @param data [Hash] Additional data that might be useful. Currently,
|
|
210
|
-
# the {Toys::ToolDefinition} is passed with key `:tool`. Future
|
|
211
|
-
# versions of Toys may provide additional information.
|
|
212
|
-
# @return [Array<Toys::WrappableString,String,Array<String>>] The default
|
|
213
|
-
# long description. See {Toys::DSL::Tool#long_desc} for info on the
|
|
214
|
-
# format.
|
|
215
|
-
# @return [nil] if this middleware should not set the long description.
|
|
216
|
-
#
|
|
217
|
-
def generate_flag_group_long_desc(group, data)
|
|
218
|
-
# Source available in the toys-core gem
|
|
219
|
-
end
|
|
220
|
-
end
|
|
221
|
-
end
|
|
222
|
-
end
|