toys 0.12.2 → 0.13.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/.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,185 @@
|
|
1
|
+
module Toys
|
2
|
+
module Utils
|
3
|
+
##
|
4
|
+
# **_Defined in the toys-core gem_**
|
5
|
+
#
|
6
|
+
# A helper class that activates and installs gems and sets up bundler.
|
7
|
+
#
|
8
|
+
# This class is not loaded by default. Before using it directly, you should
|
9
|
+
# `require "toys/utils/gems"`
|
10
|
+
#
|
11
|
+
class Gems
|
12
|
+
##
|
13
|
+
# **_Defined in the toys-core gem_**
|
14
|
+
#
|
15
|
+
# Failed to activate a gem.
|
16
|
+
#
|
17
|
+
class ActivationFailedError < ::StandardError
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
# **_Defined in the toys-core gem_**
|
22
|
+
#
|
23
|
+
# Failed to install a gem.
|
24
|
+
#
|
25
|
+
class InstallFailedError < ActivationFailedError
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# **_Defined in the toys-core gem_**
|
30
|
+
#
|
31
|
+
# Need to add a gem to the bundle.
|
32
|
+
#
|
33
|
+
class GemfileUpdateNeededError < ActivationFailedError
|
34
|
+
##
|
35
|
+
# Create a GemfileUpdateNeededError.
|
36
|
+
#
|
37
|
+
# @param requirements_text [String] Gems and versions missing.
|
38
|
+
# @param gemfile_path [String] Path to the offending Gemfile.
|
39
|
+
#
|
40
|
+
def initialize(requirements_text, gemfile_path)
|
41
|
+
# Source available in the toys-core gem
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# **_Defined in the toys-core gem_**
|
47
|
+
#
|
48
|
+
# Failed to run Bundler
|
49
|
+
#
|
50
|
+
class BundlerFailedError < ::StandardError
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# **_Defined in the toys-core gem_**
|
55
|
+
#
|
56
|
+
# Could not find a Gemfile
|
57
|
+
#
|
58
|
+
class GemfileNotFoundError < BundlerFailedError
|
59
|
+
end
|
60
|
+
|
61
|
+
##
|
62
|
+
# **_Defined in the toys-core gem_**
|
63
|
+
#
|
64
|
+
# The bundle is not and could not be installed
|
65
|
+
#
|
66
|
+
class BundleNotInstalledError < BundlerFailedError
|
67
|
+
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# **_Defined in the toys-core gem_**
|
71
|
+
#
|
72
|
+
# Bundler has already been run; cannot do so again
|
73
|
+
#
|
74
|
+
class AlreadyBundledError < BundlerFailedError
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
# **_Defined in the toys-core gem_**
|
79
|
+
#
|
80
|
+
# The bundle contained a toys or toys-core dependency that is
|
81
|
+
# incompatible with the currently running version.
|
82
|
+
#
|
83
|
+
class IncompatibleToysError < BundlerFailedError
|
84
|
+
end
|
85
|
+
|
86
|
+
##
|
87
|
+
# The gemfile names that are searched by default.
|
88
|
+
# @return [Array<String>]
|
89
|
+
#
|
90
|
+
DEFAULT_GEMFILE_NAMES = [".gems.rb", "gems.rb", "Gemfile"].freeze
|
91
|
+
|
92
|
+
##
|
93
|
+
# Activate the given gem. If it is not present, attempt to install it (or
|
94
|
+
# inform the user to update the bundle).
|
95
|
+
#
|
96
|
+
# @param name [String] Name of the gem
|
97
|
+
# @param requirements [String...] Version requirements
|
98
|
+
# @return [void]
|
99
|
+
#
|
100
|
+
def self.activate(name, *requirements)
|
101
|
+
# Source available in the toys-core gem
|
102
|
+
end
|
103
|
+
|
104
|
+
##
|
105
|
+
# Create a new gem activator.
|
106
|
+
#
|
107
|
+
# @param on_missing [:confirm,:error,:install] What to do if a needed gem
|
108
|
+
# is not installed. Possible values:
|
109
|
+
#
|
110
|
+
# * `:confirm` - prompt the user on whether to install
|
111
|
+
# * `:error` - raise an exception
|
112
|
+
# * `:install` - just install the gem
|
113
|
+
#
|
114
|
+
# The default is `:confirm`.
|
115
|
+
#
|
116
|
+
# @param on_conflict [:error,:warn,:ignore] What to do if bundler has
|
117
|
+
# already been run with a different Gemfile. Possible values:
|
118
|
+
#
|
119
|
+
# * `:error` - raise an exception
|
120
|
+
# * `:ignore` - just silently proceed without bundling again
|
121
|
+
# * `:warn` - print a warning and proceed without bundling again
|
122
|
+
#
|
123
|
+
# The default is `:error`.
|
124
|
+
#
|
125
|
+
# @param terminal [Toys::Utils::Terminal] Terminal to use (optional)
|
126
|
+
# @param input [IO] Input IO (optional, defaults to STDIN)
|
127
|
+
# @param output [IO] Output IO (optional, defaults to STDOUT)
|
128
|
+
# @param suppress_confirm [Boolean] Deprecated. Use `on_missing` instead.
|
129
|
+
# @param default_confirm [Boolean] Deprecated. Use `on_missing` instead.
|
130
|
+
#
|
131
|
+
def initialize(on_missing: nil,
|
132
|
+
on_conflict: nil,
|
133
|
+
terminal: nil,
|
134
|
+
input: nil,
|
135
|
+
output: nil,
|
136
|
+
suppress_confirm: nil,
|
137
|
+
default_confirm: nil)
|
138
|
+
# Source available in the toys-core gem
|
139
|
+
end
|
140
|
+
|
141
|
+
##
|
142
|
+
# Activate the given gem. If it is not present, attempt to install it (or
|
143
|
+
# inform the user to update the bundle).
|
144
|
+
#
|
145
|
+
# @param name [String] Name of the gem
|
146
|
+
# @param requirements [String...] Version requirements
|
147
|
+
# @return [void]
|
148
|
+
#
|
149
|
+
def activate(name, *requirements)
|
150
|
+
# Source available in the toys-core gem
|
151
|
+
end
|
152
|
+
|
153
|
+
##
|
154
|
+
# Search for an appropriate Gemfile, and set up the bundle.
|
155
|
+
#
|
156
|
+
# @param groups [Array<String>] The groups to include in setup.
|
157
|
+
#
|
158
|
+
# @param gemfile_path [String] The path to the Gemfile to use. If `nil`
|
159
|
+
# or not given, the `:search_dirs` will be searched for a Gemfile.
|
160
|
+
#
|
161
|
+
# @param search_dirs [String,Array<String>] Directories in which to
|
162
|
+
# search for a Gemfile, if gemfile_path is not given. You can provide
|
163
|
+
# a single directory or an array of directories.
|
164
|
+
#
|
165
|
+
# @param gemfile_names [String,Array<String>] File names that are
|
166
|
+
# recognized as Gemfiles, when searching because gemfile_path is not
|
167
|
+
# given. Defaults to {DEFAULT_GEMFILE_NAMES}.
|
168
|
+
#
|
169
|
+
# @param retries [Integer] Number of times to retry bundler operations.
|
170
|
+
# Optional.
|
171
|
+
#
|
172
|
+
# @return [void]
|
173
|
+
#
|
174
|
+
def bundle(groups: nil,
|
175
|
+
gemfile_path: nil,
|
176
|
+
search_dirs: nil,
|
177
|
+
gemfile_names: nil,
|
178
|
+
retries: nil)
|
179
|
+
# Source available in the toys-core gem
|
180
|
+
end
|
181
|
+
|
182
|
+
@global_mutex = ::Monitor.new
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -0,0 +1,353 @@
|
|
1
|
+
module Toys
|
2
|
+
module Utils
|
3
|
+
##
|
4
|
+
# **_Defined in the toys-core gem_**
|
5
|
+
#
|
6
|
+
# This object provides cached access to remote git data. Given a remote
|
7
|
+
# repository, a path, and a commit, it makes the files availble in the
|
8
|
+
# local filesystem. Access is cached, so repeated requests for the same
|
9
|
+
# commit and path in the same repo do not hit the remote repository again.
|
10
|
+
#
|
11
|
+
# This class is used by the Loader to load tools from git. Tools can also
|
12
|
+
# use the `:git_cache` mixin for direct access to this class.
|
13
|
+
#
|
14
|
+
class GitCache
|
15
|
+
##
|
16
|
+
# **_Defined in the toys-core gem_**
|
17
|
+
#
|
18
|
+
# GitCache encountered a failure
|
19
|
+
#
|
20
|
+
class Error < ::StandardError
|
21
|
+
##
|
22
|
+
# Create a GitCache::Error.
|
23
|
+
#
|
24
|
+
# @param message [String] The error message
|
25
|
+
# @param result [Toys::Utils::Exec::Result] The result of a git
|
26
|
+
# command execution, or `nil` if this error was not due to a git
|
27
|
+
# command error.
|
28
|
+
#
|
29
|
+
def initialize(message, result)
|
30
|
+
# Source available in the toys-core gem
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# @return [Toys::Utils::Exec::Result] The result of a git command
|
35
|
+
# execution, or `nil` if this error was not due to a git command
|
36
|
+
# error.
|
37
|
+
#
|
38
|
+
attr_reader :exec_result
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# **_Defined in the toys-core gem_**
|
43
|
+
#
|
44
|
+
# Information about a remote git repository in the cache.
|
45
|
+
#
|
46
|
+
# This object is returned from {GitCache#repo_info}.
|
47
|
+
#
|
48
|
+
class RepoInfo
|
49
|
+
include ::Comparable
|
50
|
+
|
51
|
+
##
|
52
|
+
# The base directory of this git repository's cache entry. This
|
53
|
+
# directory contains all cached data related to this repo. Deleting it
|
54
|
+
# effectively removes the repo from the cache.
|
55
|
+
#
|
56
|
+
# @return [String]
|
57
|
+
#
|
58
|
+
attr_reader :base_dir
|
59
|
+
|
60
|
+
##
|
61
|
+
# The git remote, usually a file system path or URL.
|
62
|
+
#
|
63
|
+
# @return [String]
|
64
|
+
#
|
65
|
+
attr_reader :remote
|
66
|
+
|
67
|
+
##
|
68
|
+
# The last time any cached data from this repo was accessed, or `nil`
|
69
|
+
# if the information is unavailable.
|
70
|
+
#
|
71
|
+
# @return [Time,nil]
|
72
|
+
#
|
73
|
+
attr_reader :last_accessed
|
74
|
+
|
75
|
+
##
|
76
|
+
# A list of git refs (branches, tags, shas) that have been accessed
|
77
|
+
# from this repo.
|
78
|
+
#
|
79
|
+
# @return [Array<RefInfo>]
|
80
|
+
#
|
81
|
+
attr_reader :refs
|
82
|
+
|
83
|
+
##
|
84
|
+
# A list of shared source files and directories accessed for this repo.
|
85
|
+
#
|
86
|
+
# @return [Array<SourceInfo>]
|
87
|
+
#
|
88
|
+
attr_reader :sources
|
89
|
+
|
90
|
+
##
|
91
|
+
# Convert this RepoInfo to a hash suitable for JSON output
|
92
|
+
#
|
93
|
+
# @return [Hash]
|
94
|
+
#
|
95
|
+
def to_h
|
96
|
+
# Source available in the toys-core gem
|
97
|
+
end
|
98
|
+
|
99
|
+
##
|
100
|
+
# Comparison function
|
101
|
+
#
|
102
|
+
# @param other [RepoInfo]
|
103
|
+
# @return [Integer]
|
104
|
+
#
|
105
|
+
def <=>(other)
|
106
|
+
# Source available in the toys-core gem
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
##
|
111
|
+
# **_Defined in the toys-core gem_**
|
112
|
+
#
|
113
|
+
# Information about a git ref used in a cache.
|
114
|
+
#
|
115
|
+
class RefInfo
|
116
|
+
include ::Comparable
|
117
|
+
|
118
|
+
##
|
119
|
+
# The git ref
|
120
|
+
#
|
121
|
+
# @return [String]
|
122
|
+
#
|
123
|
+
attr_reader :ref
|
124
|
+
|
125
|
+
##
|
126
|
+
# The git sha last associated with the ref
|
127
|
+
#
|
128
|
+
# @return [String]
|
129
|
+
#
|
130
|
+
attr_reader :sha
|
131
|
+
|
132
|
+
##
|
133
|
+
# The timestamp when this ref was last accessed
|
134
|
+
#
|
135
|
+
# @return [Time]
|
136
|
+
#
|
137
|
+
attr_reader :last_accessed
|
138
|
+
|
139
|
+
##
|
140
|
+
# The timestamp when this ref was last updated
|
141
|
+
#
|
142
|
+
# @return [Time]
|
143
|
+
#
|
144
|
+
attr_reader :last_updated
|
145
|
+
|
146
|
+
##
|
147
|
+
# Convert this RefInfo to a hash suitable for JSON output
|
148
|
+
#
|
149
|
+
# @return [Hash]
|
150
|
+
#
|
151
|
+
def to_h
|
152
|
+
# Source available in the toys-core gem
|
153
|
+
end
|
154
|
+
|
155
|
+
##
|
156
|
+
# Comparison function
|
157
|
+
#
|
158
|
+
# @param other [RefInfo]
|
159
|
+
# @return [Integer]
|
160
|
+
#
|
161
|
+
def <=>(other)
|
162
|
+
# Source available in the toys-core gem
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
##
|
167
|
+
# **_Defined in the toys-core gem_**
|
168
|
+
#
|
169
|
+
# Information about shared source files provided from the cache.
|
170
|
+
#
|
171
|
+
class SourceInfo
|
172
|
+
include ::Comparable
|
173
|
+
|
174
|
+
##
|
175
|
+
# The git sha the source comes from
|
176
|
+
#
|
177
|
+
# @return [String]
|
178
|
+
#
|
179
|
+
attr_reader :sha
|
180
|
+
|
181
|
+
##
|
182
|
+
# The path within the git repo
|
183
|
+
#
|
184
|
+
# @return [String]
|
185
|
+
#
|
186
|
+
attr_reader :git_path
|
187
|
+
|
188
|
+
##
|
189
|
+
# The path to the source file or directory
|
190
|
+
#
|
191
|
+
# @return [String]
|
192
|
+
#
|
193
|
+
attr_reader :source
|
194
|
+
|
195
|
+
##
|
196
|
+
# The timestamp when this ref was last accessed
|
197
|
+
#
|
198
|
+
# @return [Time]
|
199
|
+
#
|
200
|
+
attr_reader :last_accessed
|
201
|
+
|
202
|
+
##
|
203
|
+
# Convert this SourceInfo to a hash suitable for JSON output
|
204
|
+
#
|
205
|
+
# @return [Hash]
|
206
|
+
#
|
207
|
+
def to_h
|
208
|
+
# Source available in the toys-core gem
|
209
|
+
end
|
210
|
+
|
211
|
+
##
|
212
|
+
# Comparison function
|
213
|
+
#
|
214
|
+
# @param other [SourceInfo]
|
215
|
+
# @return [Integer]
|
216
|
+
#
|
217
|
+
def <=>(other)
|
218
|
+
# Source available in the toys-core gem
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
##
|
223
|
+
# Access a git cache.
|
224
|
+
#
|
225
|
+
# @param cache_dir [String] The path to the cache directory. Defaults to
|
226
|
+
# a specific directory in the user's XDG cache.
|
227
|
+
#
|
228
|
+
def initialize(cache_dir: nil)
|
229
|
+
# Source available in the toys-core gem
|
230
|
+
end
|
231
|
+
|
232
|
+
##
|
233
|
+
# The cache directory.
|
234
|
+
#
|
235
|
+
# @return [String]
|
236
|
+
#
|
237
|
+
attr_reader :cache_dir
|
238
|
+
|
239
|
+
##
|
240
|
+
# Get the given git-based files from the git cache, loading from the
|
241
|
+
# remote repo if necessary.
|
242
|
+
#
|
243
|
+
# The resulting files are either copied into a directory you provide in
|
244
|
+
# the `:into` parameter, or populated into a _shared_ source directory if
|
245
|
+
# you omit the `:info` parameter. In the latter case, it is important
|
246
|
+
# that you do not modify the returned files or directories, nor add or
|
247
|
+
# remove any files from the directories returned, to avoid confusing
|
248
|
+
# callers that could be given the same directory. If you need to make any
|
249
|
+
# modifications to the returned files, use `:into` to provide your own
|
250
|
+
# private directory.
|
251
|
+
#
|
252
|
+
# @param remote [String] The URL of the git repo. Required.
|
253
|
+
# @param path [String] The path to the file or directory within the repo.
|
254
|
+
# Optional. Defaults to the entire repo.
|
255
|
+
# @param commit [String] The commit reference, which may be a SHA or any
|
256
|
+
# git ref such as a branch or tag. Optional. Defaults to `HEAD`.
|
257
|
+
# @param into [String] If provided, copies the specified files into the
|
258
|
+
# given directory path. If omitted or `nil`, populates and returns a
|
259
|
+
# shared source file or directory.
|
260
|
+
# @param update [Boolean,Integer] Whether to update of non-SHA commit
|
261
|
+
# references if they were previously loaded. This is useful, for
|
262
|
+
# example, if the commit is `HEAD` or a branch name. Pass `true` or
|
263
|
+
# `false` to specify whether to update, or an integer to update if
|
264
|
+
# last update was done at least that many seconds ago. Default is
|
265
|
+
# `false`.
|
266
|
+
#
|
267
|
+
# @return [String] The full path to the cached files. The returned path
|
268
|
+
# will correspod to the path given. For example, if you provide the
|
269
|
+
# path `Gemfile` representing a single file in the repository, the
|
270
|
+
# returned path will point directly to the cached copy of that file.
|
271
|
+
#
|
272
|
+
def get(remote, path: nil, commit: nil, into: nil, update: false, timestamp: nil)
|
273
|
+
# Source available in the toys-core gem
|
274
|
+
end
|
275
|
+
alias find get
|
276
|
+
|
277
|
+
##
|
278
|
+
# Returns an array of the known remote names.
|
279
|
+
#
|
280
|
+
# @return [Array<String>]
|
281
|
+
#
|
282
|
+
def remotes
|
283
|
+
# Source available in the toys-core gem
|
284
|
+
end
|
285
|
+
|
286
|
+
##
|
287
|
+
# Returns a {RepoInfo} describing the cache for the given remote, or
|
288
|
+
# `nil` if the given remote has never been cached.
|
289
|
+
#
|
290
|
+
# @param remote [String] Remote name for a repo
|
291
|
+
# @return [RepoInfo,nil]
|
292
|
+
#
|
293
|
+
def repo_info(remote)
|
294
|
+
# Source available in the toys-core gem
|
295
|
+
end
|
296
|
+
|
297
|
+
##
|
298
|
+
# Removes caches for the given repos, or all repos if specified.
|
299
|
+
#
|
300
|
+
# Removes all cache information for the specified repositories, including
|
301
|
+
# local clones and shared source directories. The next time these
|
302
|
+
# repositories are requested, they will be reloaded from the remote
|
303
|
+
# repository from scratch.
|
304
|
+
#
|
305
|
+
# Be careful not to remove repos that are currently in use by other
|
306
|
+
# GitCache clients.
|
307
|
+
#
|
308
|
+
# @param remotes [Array<String>,:all] The remotes to remove.
|
309
|
+
# @return [Array<String>] The remotes actually removed.
|
310
|
+
#
|
311
|
+
def remove_repos(remotes)
|
312
|
+
# Source available in the toys-core gem
|
313
|
+
end
|
314
|
+
|
315
|
+
##
|
316
|
+
# Remove records of the given refs (i.e. branches, tags, or `HEAD`) from
|
317
|
+
# the given repository's cache. The next time those refs are requested,
|
318
|
+
# they will be pulled from the remote repo.
|
319
|
+
#
|
320
|
+
# If you provide the `refs:` argument, only those refs are removed.
|
321
|
+
# Otherwise, all refs are removed.
|
322
|
+
#
|
323
|
+
# @param remote [String] The repository
|
324
|
+
# @param refs [Array<String>] The refs to remove. Optional.
|
325
|
+
# @return [Array<RefInfo>,nil] The refs actually forgotten, or `nil` if
|
326
|
+
# the given repo is not in the cache.
|
327
|
+
#
|
328
|
+
def remove_refs(remote, refs: nil)
|
329
|
+
# Source available in the toys-core gem
|
330
|
+
end
|
331
|
+
|
332
|
+
##
|
333
|
+
# Removes shared sources for the given cache. The next time a client
|
334
|
+
# requests them, the removed sources will be recopied from the repo.
|
335
|
+
#
|
336
|
+
# If you provide the `commits:` argument, only sources associated with
|
337
|
+
# those commits are removed. Otherwise, all sources are removed.
|
338
|
+
#
|
339
|
+
# Be careful not to remove sources that are currently in use by other
|
340
|
+
# GitCache clients.
|
341
|
+
#
|
342
|
+
# @param remote [String] The repository
|
343
|
+
# @param commits [Array<String>] Remove only the sources for the given
|
344
|
+
# commits. Optional.
|
345
|
+
# @return [Array<SourceInfo>,nil] The sources actually removed, or `nil`
|
346
|
+
# if the given repo is not in the cache.
|
347
|
+
#
|
348
|
+
def remove_sources(remote, commits: nil)
|
349
|
+
# Source available in the toys-core gem
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|
353
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
module Toys
|
2
|
+
module Utils
|
3
|
+
##
|
4
|
+
# **_Defined in the toys-core gem_**
|
5
|
+
#
|
6
|
+
# A helper class that generates usage documentation for a tool.
|
7
|
+
#
|
8
|
+
# This class generates full usage documentation, including description,
|
9
|
+
# flags, and arguments. It is used by middleware that implements help
|
10
|
+
# and related options.
|
11
|
+
#
|
12
|
+
# This class is not loaded by default. Before using it directly, you should
|
13
|
+
# `require "toys/utils/help_text"`
|
14
|
+
#
|
15
|
+
class HelpText
|
16
|
+
##
|
17
|
+
# Default width of first column
|
18
|
+
# @return [Integer]
|
19
|
+
#
|
20
|
+
DEFAULT_LEFT_COLUMN_WIDTH = 32
|
21
|
+
|
22
|
+
##
|
23
|
+
# Default indent
|
24
|
+
# @return [Integer]
|
25
|
+
#
|
26
|
+
DEFAULT_INDENT = 4
|
27
|
+
|
28
|
+
##
|
29
|
+
# Create a usage helper given an execution context.
|
30
|
+
#
|
31
|
+
# @param context [Toys::Context] The current context.
|
32
|
+
# @return [Toys::Utils::HelpText]
|
33
|
+
#
|
34
|
+
def self.from_context(context)
|
35
|
+
# Source available in the toys-core gem
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Create a usage helper.
|
40
|
+
#
|
41
|
+
# @param tool [Toys::ToolDefinition] The tool to document.
|
42
|
+
# @param loader [Toys::Loader] A loader that can provide subcommands.
|
43
|
+
# @param executable_name [String] The name of the executable.
|
44
|
+
# e.g. `"toys"`.
|
45
|
+
# @param delegates [Array<Toys::ToolDefinition>] The delegation path to
|
46
|
+
# the tool.
|
47
|
+
#
|
48
|
+
# @return [Toys::Utils::HelpText]
|
49
|
+
#
|
50
|
+
def initialize(tool, loader, executable_name, delegates: [])
|
51
|
+
# Source available in the toys-core gem
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# The ToolDefinition being documented.
|
56
|
+
# @return [Toys::ToolDefinition]
|
57
|
+
#
|
58
|
+
attr_reader :tool
|
59
|
+
|
60
|
+
##
|
61
|
+
# Generate a short usage string.
|
62
|
+
#
|
63
|
+
# @param recursive [Boolean] If true, and the tool is a namespace,
|
64
|
+
# display all subtools recursively. Defaults to false.
|
65
|
+
# @param include_hidden [Boolean] Include hidden subtools (i.e. whose
|
66
|
+
# names begin with underscore.) Default is false.
|
67
|
+
# @param separate_sources [Boolean] Split up tool list by source root.
|
68
|
+
# Defaults to false.
|
69
|
+
# @param left_column_width [Integer] Width of the first column. Default
|
70
|
+
# is {DEFAULT_LEFT_COLUMN_WIDTH}.
|
71
|
+
# @param indent [Integer] Indent width. Default is {DEFAULT_INDENT}.
|
72
|
+
# @param wrap_width [Integer,nil] Overall width to wrap to. Default is
|
73
|
+
# `nil` indicating no wrapping.
|
74
|
+
#
|
75
|
+
# @return [String] A usage string.
|
76
|
+
#
|
77
|
+
def usage_string(recursive: false, include_hidden: false, separate_sources: false,
|
78
|
+
left_column_width: nil, indent: nil, wrap_width: nil)
|
79
|
+
# Source available in the toys-core gem
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# Generate a long help string.
|
84
|
+
#
|
85
|
+
# @param recursive [Boolean] If true, and the tool is a namespace,
|
86
|
+
# display all subtools recursively. Defaults to false.
|
87
|
+
# @param search [String,nil] An optional string to search for when
|
88
|
+
# listing subtools. Defaults to `nil` which finds all subtools.
|
89
|
+
# @param include_hidden [Boolean] Include hidden subtools (i.e. whose
|
90
|
+
# names begin with underscore.) Default is false.
|
91
|
+
# @param show_source_path [Boolean] If true, shows the source path
|
92
|
+
# section. Defaults to false.
|
93
|
+
# @param separate_sources [Boolean] Split up tool list by source root.
|
94
|
+
# Defaults to false.
|
95
|
+
# @param indent [Integer] Indent width. Default is {DEFAULT_INDENT}.
|
96
|
+
# @param indent2 [Integer] Second indent width. Default is
|
97
|
+
# {DEFAULT_INDENT}.
|
98
|
+
# @param wrap_width [Integer,nil] Wrap width of the column, or `nil` to
|
99
|
+
# disable wrap. Default is `nil`.
|
100
|
+
# @param styled [Boolean] Output ansi styles. Default is `true`.
|
101
|
+
#
|
102
|
+
# @return [String] A usage string.
|
103
|
+
#
|
104
|
+
def help_string(recursive: false, search: nil, include_hidden: false,
|
105
|
+
show_source_path: false, separate_sources: false,
|
106
|
+
indent: nil, indent2: nil, wrap_width: nil, styled: true)
|
107
|
+
# Source available in the toys-core gem
|
108
|
+
end
|
109
|
+
|
110
|
+
##
|
111
|
+
# Generate a subtool list string.
|
112
|
+
#
|
113
|
+
# @param recursive [Boolean] If true, and the tool is a namespace,
|
114
|
+
# display all subtools recursively. Defaults to false.
|
115
|
+
# @param search [String,nil] An optional string to search for when
|
116
|
+
# listing subtools. Defaults to `nil` which finds all subtools.
|
117
|
+
# @param include_hidden [Boolean] Include hidden subtools (i.e. whose
|
118
|
+
# names begin with underscore.) Default is false.
|
119
|
+
# @param separate_sources [Boolean] Split up tool list by source root.
|
120
|
+
# Defaults to false.
|
121
|
+
# @param indent [Integer] Indent width. Default is {DEFAULT_INDENT}.
|
122
|
+
# @param wrap_width [Integer,nil] Wrap width of the column, or `nil` to
|
123
|
+
# disable wrap. Default is `nil`.
|
124
|
+
# @param styled [Boolean] Output ansi styles. Default is `true`.
|
125
|
+
#
|
126
|
+
# @return [String] A usage string.
|
127
|
+
#
|
128
|
+
def list_string(recursive: false, search: nil, include_hidden: false,
|
129
|
+
separate_sources: false, indent: nil, wrap_width: nil, styled: true)
|
130
|
+
# Source available in the toys-core gem
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|