toys 0.23.0 → 0.25.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee5fe663d934949887ff7ce01289453e7b59efcc553331e2efb8a8ae949b626b
4
- data.tar.gz: c34a38d893789bdb14fc159f211ac83b09a39b2d897601c961755876be2b6d28
3
+ metadata.gz: e494ced1b44b862aee77dd732210549374c571b55b4da8d503034ef3f87bba6f
4
+ data.tar.gz: bceadfc53e8b691951eef4ea4ef6d8b2f666590f745185322577d4bb5ccff82e
5
5
  SHA512:
6
- metadata.gz: 0fd0c5c2edfe80ede91db110a513bfe176766b4d3c8a75e378721296b8fe4c7c5681e07695fa249f9efede159ffb9feff43524d3ad085f98ca7498af9433c3d1
7
- data.tar.gz: 5345ecacee610f36dd439f7adf8b1118a1cc0ecb858f19a5f3c938a5e86a33fb19be94fff5173e3170d1bac6b8ed4309fc54192f5542573e15a7109ddeaba9e2
6
+ metadata.gz: 40b86310b2d3ad6ce6b16ba738f4d8f543943f008a41b77fdc91b8f858afe50fa2104b3adebb2719aba98e6e920ce7f86f5df00a3c9d8824b4ea85e395fa5710
7
+ data.tar.gz: e468cd88b4042956bf12cbead2316c592799e667d61299ae69ab66d7cf457f5cef727a3d3cbb1589c3bf3cc16d76a89f8e8c4fff036a343fc6ad5a488456c2c9
data/.yardopts CHANGED
@@ -1,7 +1,6 @@
1
1
  --no-private
2
2
  --title=Toys
3
3
  --markup=markdown
4
- --markup-provider redcarpet
5
4
  --main=README.md
6
5
  ./core-docs/toys/**/*.rb
7
6
  ./core-docs/toys-core.rb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # Release History
2
2
 
3
+ ### v0.25.0 / 2026-10-10
4
+
5
+ This is a release candidate release toward version 1.0. It includes a variety of fixes and small features, largely around adherence to clig.dev and other common CLI guidelines.
6
+
7
+ * Major updates
8
+ * ADDED: The `-h` flag is now a standard help flag, similar to `--help`.
9
+ * Updates to tool lookup
10
+ * ADDED: Toys now loads global tools from the XDG config directories
11
+ * ADDED: The `TOYS_GLOBAL_SOURCES` environment variable selects which global sources are searched
12
+ * BREAKING CHANGE: The `TOYS_PATH` environment variable is no longer supported. Use `XDG_CONFIG_HOME`, `XDG_CONFIG_DIRS`, or `TOYS_GLOBAL_SOURCES` instead.
13
+ * BREAKING CHANGE: Toys no longer loads global tools from `/etc/.toys.rb` or `/etc/.toys/`. Move them into `/etc/xdg/toys` instead.
14
+ * BREAKING CHANGE: Removed the `Toys::StandardCLI::TOYS_PATH_ENV` constant.
15
+ * Updates to logging and warnings
16
+ * ADDED: Warnings are displayed when a tool invokes a deprecated interface. They can be turned off by setting `TOYS_SUPPRESS_WARNINGS` to a nonempty value.
17
+ * ADDED: Logs display with a simplified severity prefix unless verbosity is positive
18
+ * FIXED: The `DEBUG` log prefix is no longer colored white
19
+ * FIXED: Logs emitted from tool initializers honor the verbosity
20
+ * Updates to ANSI coloring control
21
+ * ADDED: The `FORCE_COLOR` environment variable forces styled output on, or off when set to 0 or false
22
+ * FIXED: An empty `NO_COLOR` environment variable no longer disables styled output, per the no-color.org spec
23
+ * FIXED: Styled output is disabled when the `TERM` environment variable is set to `dumb`
24
+ * FIXED: The highline mixin decides whether to use color from its own output stream, and honors `NO_COLOR`, `FORCE_COLOR`, and `TERM=dumb`
25
+ * FIXED: Help text displayed through a pager honors the styled output setting, including `NO_COLOR`, `FORCE_COLOR`, and `TERM=dumb`
26
+ * Other fixes
27
+ * FIXED: Bash tab completion discards stderr from the completion command, preventing unwanted output if warnings are emitted.
28
+ * FIXED: Tool-not-found suggestions include namespaces
29
+ * FIXED: The `:push` handler creates a new array rather than appending in place, so that a frozen or non-cloneable default doesn't cause problems
30
+ * FIXED: Re-vendor `simple_xdg` 0.1.2 to pick up home directory fix
31
+ * FIXED: Re-vendor `git_cache` 0.2.0 to report an unwritable cache directory clearly and fix repo lock races
32
+
33
+ ### v0.24.0 / 2026-09-11
34
+
35
+ * Feature: The `toys do` builtin provides an `--on-missing-gem` flag that governs how the `--gem` flag handles gems that are not installed.
36
+ * BREAKING CHANGE: Removed deprecated `gem_version:` argument from `:rspec` and `:minitest` templates.
37
+
3
38
  ### v0.23.0 / 2026-09-09
4
39
 
5
40
  This is a major release, with several new features. It also includes a significant refactor of some of the underlying layers, which should be mostly invisible. It is a release candidate for the upcoming version 1.0.
data/README.md CHANGED
@@ -108,9 +108,10 @@ Toys searches up the directory hierarchy for Toys files. So it will find this
108
108
  also read multiple files if it finds them, so you can "scope" your tools more
109
109
  specifically or generally by locating them in your directory hierarchy.
110
110
 
111
- If you want to define "global" tools that apply anywhere, write a Toys file
112
- either in your home directory, or in the system configuration directory
113
- (usually `/etc`). Toys always searches these locations.
111
+ If you want to define "global" tools that apply anywhere, write a Toys file in
112
+ your home directory, or put tool files in the `toys` directory under your user
113
+ configuration directory (usually `~/.config/toys`) or the system configuration
114
+ directory (usually `/etc/xdg/toys`). Toys searches these locations by default.
114
115
 
115
116
  ### A more sophisticated example
116
117
 
data/bin/toys CHANGED
@@ -8,4 +8,11 @@ $LOAD_PATH.delete(::ENV["TOYS_LIB_PATH"])
8
8
  $LOAD_PATH.unshift(::ENV["TOYS_LIB_PATH"])
9
9
  require "toys"
10
10
 
11
- exit(::Toys::StandardCLI.new.run(::ARGV))
11
+ begin
12
+ cli = ::Toys::StandardCLI.new
13
+ rescue ::Toys::StandardCLI::InvalidGlobalSourcesError => e
14
+ # Not Kernel#warn, which -W0 would silence, hiding why toys exited.
15
+ $stderr.puts(e.message) # rubocop:disable Style/StderrPuts
16
+ exit(2)
17
+ end
18
+ exit(cli.run(::ARGV))
data/builtins/do.rb CHANGED
@@ -17,16 +17,10 @@ long_desc \
17
17
  "The --delim flag must appear first before the tools to run. Any flags that appear later in" \
18
18
  " the command line will be passed to the tools themselves.",
19
19
  "",
20
- "You may also make additional tools available to the tools you run, by passing the --gem," \
21
- " --git, and --path flags. Each adds a source of tools, which takes priority over the" \
22
- " tools that would otherwise be found. The three flags may be repeated and interleaved," \
23
- " and the source added by the leftmost flag takes priority over the sources added by the" \
24
- " flags to its right. For example:",
25
- [" toys do --gem=my-tools --git=https://github.com/dazuma/example deploy --migrate"],
26
- "Here, a tool defined by both sources is taken from the gem. See the descriptions of the" \
27
- " individual flags below for the syntax of their values. Note that the commas within those" \
28
- " values are part of the flag value, and are unrelated to the delimiter that separates the" \
29
- " tools to run."
20
+ "You may also load tools from additional sources, by passing the --gem, --git, and --path" \
21
+ " flags. Any number of these flags can be added; each adds a source of tools, with earlier" \
22
+ " flags taking priority over later. For example:",
23
+ [" toys do --gem=my-tools --git=https://github.com/dazuma/example deploy --migrate"]
30
24
 
31
25
  flag :delim do
32
26
  flags "-d", "--delim=VALUE"
@@ -49,7 +43,9 @@ flag :sources do
49
43
  default []
50
44
  desc "Make the tools from the given gem available"
51
45
  long_desc \
52
- "Adds the tools from the given gem, prompting to install the gem if it is not present.",
46
+ "Adds the tools from the given gem. If the specified gem is not currently installed," \
47
+ " follows the policy set by the --on-missing-gem flag, which is normally to prompt" \
48
+ " whether to install.",
53
49
  "",
54
50
  "The value is the gem name, optionally followed by any number of version requirements," \
55
51
  " all separated by commas. Whitespace surrounding each element is ignored. The version" \
@@ -67,21 +63,18 @@ flag :sources do
67
63
  " if it is not already there.",
68
64
  "",
69
65
  "The value is the git remote (i.e. the repository URL or path), optionally followed by any" \
70
- " number of \"key=value\" elements, all separated by commas. Whitespace surrounding each" \
71
- " element, and surrounding each equals sign, is ignored. For example:",
66
+ " number of \"key=value\" elements, all separated by commas. There is no way to escape" \
67
+ " a comma appearing within the value. Whitespace surrounding each element, and surrounding" \
68
+ " each equals sign, is ignored. For example:",
72
69
  [" --git=\"https://github.com/dazuma/example, path=toys, commit=main\""],
73
- "The recognized keys are:",
74
- [" path The file or directory within the repository to load. By default, the"],
75
- [" entire repository is loaded."],
76
- [" commit The SHA, tag, or branch to load. By default, the repository head is used."],
77
- [" update Whether to refresh a previously cached repository. Pass \"true\" or \"false\","],
78
- [" or a number of seconds, to refresh only if the cache is at least that old."],
79
- [" The default is \"false\"."],
80
- "Unlike --gem, which takes its elements positionally, the elements here are named, because" \
81
- " a git source has three independent optional fields and a positional syntax could not" \
82
- " express, for example, a path with no commit.",
83
70
  "",
84
- "There is no way to escape a comma appearing within the value."
71
+ "The recognized keys are:",
72
+ "* \"path\" : The file or directory within the repository to load. By default, the entire" \
73
+ " repository is loaded.",
74
+ "* \"commit\" : The SHA, tag, or branch to load. By default, the repository head is used.",
75
+ "* \"update\" : Whether to refresh a previously cached repository. Pass \"true\" or" \
76
+ " \"false\", or a number of seconds, to refresh only if the cache is at least that old." \
77
+ " The default is \"false\"."
85
78
  end
86
79
 
87
80
  flag :sources do
@@ -96,6 +89,22 @@ flag :sources do
96
89
  [" --path=/path/to/my-tools"]
97
90
  end
98
91
 
92
+ flag :on_missing_gem do
93
+ flags "--on-missing-gem=WHAT"
94
+ accept [:confirm, :install, :error]
95
+ complete_values ["confirm", "install", "error"]
96
+ desc "Specify what to do if a gem is not installed"
97
+ long_desc \
98
+ "Specifies what to do if a gem referenced by the --gem flag is not installed." \
99
+ " Possible values are:",
100
+ "* \"confirm\" : Prompt for what to do.",
101
+ "* \"install\" : Do not prompt, but just install the needed gem.",
102
+ "* \"error\" : Display an error and abort.",
103
+ "",
104
+ "Defaults to the existing CLI configuration, normally \"confirm\". Note this does not affect" \
105
+ " any other gem references such as via the \"gem\" or \"load_gem\" directives."
106
+ end
107
+
99
108
  remaining_args :commands do
100
109
  complete do |context|
101
110
  commands = context.arg_parser.data[:commands]
@@ -119,24 +128,19 @@ def run
119
128
  end
120
129
 
121
130
  # Returns the CLI used to run the requested tools. Normally this is simply the
122
- # current CLI, but if any sources were requested, we need a new CLI because
123
- # sources cannot be added to a CLI that has already started loading tools. The
124
- # new CLI copies the current sources and adds the requested ones on top of
125
- # them. The requested sources are added in reverse order so that the first flag
126
- # on the command line ends up with the highest priority.
131
+ # current CLI, but if any sources were requested, we need a new CLI with those
132
+ # sources added. Any new sources are added in reverse order so that the first
133
+ # flag on the command line ends up with the highest priority.
127
134
  #
128
135
  # All the flag values are parsed up front, in command line order, so that a
129
136
  # malformed value is reported before any source is added, and is reported
130
- # against the first offending flag rather than the last.
131
- #
132
- # All added sources are then proactively resolved and failures reported.
137
+ # against the first offending flag rather than the last. All added sources are
138
+ # then proactively resolved and failures reported.
133
139
  def build_cli
134
140
  specs = sources.map { |kind, value| parse_source_request(kind, value) }
135
141
  return cli if specs.empty?
136
- require "toys/utils/gems" if specs.any? { |spec| spec.is_a?(::Toys::SourceSpec::Gem) }
137
- tool_cli = cli.child(copy_sources: true) do |child_cli|
138
- specs.reverse_each { |spec| child_cli.add_source(spec, high_priority: true) }
139
- end
142
+ tool_cli = cli.child(copy_sources: true)
143
+ specs.reverse_each { |spec| tool_cli.add_source(spec, high_priority: true) }
140
144
  begin
141
145
  tool_cli.loader.resolve_sources
142
146
  rescue ::Toys::ToolSourceError => e
@@ -174,7 +178,7 @@ def parse_gem_request(gem_request)
174
178
  logger.fatal("Invalid version requirement for gem #{gem_name.inspect}: #{e.message}")
175
179
  exit(1)
176
180
  end
177
- ::Toys::SourceSpec.gem(gem_name, version: gem_version)
181
+ ::Toys::SourceSpec.gem(gem_name, version: gem_version, on_missing: on_missing_gem)
178
182
  end
179
183
 
180
184
  # Splits a --git flag value into the git remote and the options that follow it,
@@ -85,6 +85,8 @@ module Toys
85
85
  # as an argument, and returns a `Logger` to use when running that tool.
86
86
  # Optional. If not provided (and no global logger is set),
87
87
  # {Toys::CLI.default_logger_factory} is called to get a basic default.
88
+ # See {Toys::Runner} for how a logger can receive the verbosity of
89
+ # the run.
88
90
  # @param base_level [Integer] The logger level that should correspond
89
91
  # to zero verbosity.
90
92
  # Optional. If not provided, defaults to the level the logger has
@@ -314,8 +316,8 @@ module Toys
314
316
  # source list. If the given search directory path does not exist or does
315
317
  # not contain either the file or directory, nothing is added.
316
318
  #
317
- # The main Toys executable uses this method to load tools from directories
318
- # in the `TOYS_PATH`.
319
+ # The main Toys executable uses this method to load tools from the
320
+ # directories in its upward walk and from the home directory.
319
321
  #
320
322
  # @param search_path [String,Pathname] A directory path to search for the
321
323
  # well-known source file and directory. Must be a String or a Pathname.
@@ -349,9 +351,6 @@ module Toys
349
351
  # given directory and works up through parent directories until it reaches
350
352
  # the file system root or it encounters one of the "terminate" directories.
351
353
  #
352
- # The main Toys executable uses this method to load tools from the current
353
- # directory and its ancestors.
354
- #
355
354
  # @param start [String,Pathname,nil] The first directory path to search.
356
355
  # If not given, defaults to the current working directory. If provided,
357
356
  # must be a String or a Pathname. Paths should generally be absolute.
@@ -9,6 +9,6 @@ module Toys
9
9
  # Current version of Toys core.
10
10
  # @return [String]
11
11
  #
12
- VERSION = "0.23.0"
12
+ VERSION = "0.25.0"
13
13
  end
14
14
  end
@@ -308,38 +308,6 @@ module Toys
308
308
  # Source available in the toys-core gem
309
309
  end
310
310
 
311
- ##
312
- # Create an alias, representing an "alternate name" for a tool.
313
- #
314
- # Note: This is functionally equivalent to creating a tool with the
315
- # `:delegate_relative` option. As such, `alias_tool` is considered
316
- # deprecated.
317
- #
318
- # ### Example
319
- #
320
- # This example defines a tool and an alias pointing to it. Both the tool
321
- # name `test` and the alias `t` will then refer to the same tool.
322
- #
323
- # tool "test" do
324
- # def run
325
- # puts "Running tests..."
326
- # end
327
- # end
328
- # alias_tool "t", "test"
329
- # # Note: the following is preferred over alias_tool:
330
- # # tool "t", delegate_relative: "test"
331
- #
332
- # @param word [String] The name of the alias
333
- # @param target [String,Array<String>] Relative path to the target of the
334
- # alias. This path may be given as an array of strings, or a single
335
- # string possibly delimited by path separators.
336
- # @return [self]
337
- # @deprecated Use {#tool} and pass `:delegate_relative` instead
338
- #
339
- def alias_tool(word, target)
340
- # Source available in the toys-core gem
341
- end
342
-
343
311
  ##
344
312
  # Causes the current tool to delegate to another tool, specified by the
345
313
  # full tool name. When run, it simply invokes the target tool with the
@@ -458,6 +426,18 @@ module Toys
458
426
  # Context directory paths should generally be absolute. Relative
459
427
  # paths will be converted to absolute, using the current working
460
428
  # directory at the time of loading.
429
+ # @param on_missing [:confirm,:error,:install] What to do if the
430
+ # requested gem is not installed. Possible values:
431
+ #
432
+ # * `:confirm` - prompt the user on whether to install
433
+ # * `:error` - raise an exception
434
+ # * `:install` - just install the gem
435
+ #
436
+ # Defaults to the setting in the {Toys::Utils::Gems} utility used to
437
+ # activate the gem (usually `:confirm`).
438
+ # @param default_confirm [boolean] The default confirmation result, if
439
+ # `on_missing` is set to `:confirm`. Defaults to the setting in the
440
+ # {Toys::Utils::Gems} utility used to activate the gem (usually true).
461
441
  # @param as [String] Load into the given tool/namespace, relative to the
462
442
  # current namespace. If omitted, tools will be loaded into the
463
443
  # current namespace.
@@ -469,6 +449,8 @@ module Toys
469
449
  path: nil,
470
450
  toys_dir: nil,
471
451
  context_directory: nil,
452
+ on_missing: nil,
453
+ default_confirm: nil,
472
454
  as: nil)
473
455
  # Source available in the toys-core gem
474
456
  end
@@ -264,10 +264,12 @@ module Toys
264
264
  SET_HANDLER = proc { |val| val }
265
265
 
266
266
  ##
267
- # The push handler pushes the given value using the `<<` operator.
267
+ # The push handler appends the given value, returning a new array. The
268
+ # previous array is not modified, so a shared or frozen default array
269
+ # can be used safely.
268
270
  # @return [Proc]
269
271
  #
270
- PUSH_HANDLER = proc { |val, prev| prev.nil? ? [val] : prev << val }
272
+ PUSH_HANDLER = proc { |val, prev| prev.nil? ? [val] : prev + [val] }
271
273
 
272
274
  ##
273
275
  # The default handler is the set handler, which replaces the previous value.
@@ -34,6 +34,15 @@ module Toys
34
34
  # end
35
35
  # end
36
36
  #
37
+ # While a tool runs, the Runner sets the level of the tool's logger to reflect
38
+ # the verbosity, as described under the `base_level` parameter of
39
+ # {#initialize}. A logger can also receive the verbosity itself, by
40
+ # implementing a `verbosity` attribute: if the logger responds to both
41
+ # `verbosity` and `verbosity=`, the Runner sets it to the verbosity (an
42
+ # Integer) for the duration of the run, and restores the previous value
43
+ # afterward. This lets a logger vary its behavior, such as its formatting, by
44
+ # verbosity independently of its level.
45
+ #
37
46
  # **_Defined in the toys-core gem_**
38
47
  #
39
48
  class Runner
@@ -72,7 +81,8 @@ module Toys
72
81
  # @param logger_factory [Proc,nil] A proc that takes a
73
82
  # {Toys::ToolDefinition} as an argument, and returns a logger to use
74
83
  # when running that tool. If not given,
75
- # {Toys::Runner::DEFAULT_LOGGER_FACTORY} is used.
84
+ # {Toys::Runner::DEFAULT_LOGGER_FACTORY} is used. See {Toys::Runner}
85
+ # for how a logger can receive the verbosity of the run.
76
86
  # @param base_level [Integer,nil] The logger level that corresponds to zero
77
87
  # verbosity. If not provided, the level the logger has before a run
78
88
  # adjusts it is used (typically Logger::WARN). A run nested inside
@@ -105,10 +105,24 @@ module Toys
105
105
  # @param source_name [String,nil] The source name that will be shown in
106
106
  # documentation for tools loaded from this source. If omitted, a
107
107
  # default is generated at resolution time.
108
+ # @param on_missing [:confirm,:error,:install] What to do if the
109
+ # requested gem is not installed. Possible values:
110
+ #
111
+ # * `:confirm` - prompt the user on whether to install
112
+ # * `:error` - raise an exception
113
+ # * `:install` - just install the gem
114
+ #
115
+ # Defaults to the setting in the {Toys::Utils::Gems} utility used to
116
+ # activate the gem (usually `:confirm`).
117
+ # @param default_confirm [boolean] The default confirmation result, if
118
+ # `on_missing` is set to `:confirm`. Defaults to the setting in the
119
+ # {Toys::Utils::Gems} utility used to activate the gem (usually true).
120
+ #
108
121
  # @return [Toys::SourceSpec::Gem]
109
122
  # @raise [ArgumentError] if an argument is not a legal value.
110
123
  #
111
- def gem(name, version: nil, path: nil, toys_dir: nil, context_directory: nil, source_name: nil)
124
+ def gem(name, version: nil, path: nil, toys_dir: nil, context_directory: nil, source_name: nil,
125
+ on_missing: nil, default_confirm: nil)
112
126
  # Source available in the toys-core gem
113
127
  end
114
128
 
@@ -285,6 +299,24 @@ module Toys
285
299
  #
286
300
  attr_reader :toys_dir
287
301
 
302
+ ##
303
+ # What to do if the gem is not installed.
304
+ #
305
+ # @return [nil] to use the default behavior for the Gems util
306
+ # @return [:error] if an error should be raised
307
+ # @return [:confirm] if a confirmation prompt should be presented
308
+ # @return [:install] if the gem should be installed without confirmation
309
+ #
310
+ attr_reader :on_missing
311
+
312
+ ##
313
+ # The default response for a confirmation prompt
314
+ #
315
+ # @return [nil] to use the default behavior for the Gems util
316
+ # @return [boolean] to provide an override
317
+ #
318
+ attr_reader :default_confirm
319
+
288
320
  protected
289
321
  end
290
322
 
@@ -22,8 +22,9 @@ module Toys
22
22
  # occurs. Default is {USAGE_ERROR_EXIT_CODE}.
23
23
  # @param stream [IO] Output stream to write to. Default is stderr.
24
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`.
25
+ # with ansi styles. If `nil`, whether to display styles is inferred
26
+ # from the output stream and the environment. See
27
+ # {Toys::Utils::Terminal.infer_styled}. Default is `nil`.
27
28
  #
28
29
  def initialize(exit_code: nil, stream: $stderr, styled_output: nil)
29
30
  # Source available in the toys-core gem
@@ -17,7 +17,7 @@ module Toys
17
17
  # Default help flags
18
18
  # @return [Array<String>]
19
19
  #
20
- DEFAULT_HELP_FLAGS = ["-?", "--help"].freeze
20
+ DEFAULT_HELP_FLAGS = ["-h", "-?", "--help"].freeze
21
21
 
22
22
  ##
23
23
  # Default usage flags
@@ -165,8 +165,9 @@ module Toys
165
165
  # false) if the output stream is not a tty.
166
166
  # @param stream [IO] Output stream to write to. Default is stdout.
167
167
  # @param styled_output [boolean,nil] Cause the tool to display help text
168
- # with ansi styles. If `nil`, display styles if the output stream is
169
- # a tty. Default is `nil`.
168
+ # with ansi styles. If `nil`, whether to display styles is inferred
169
+ # from the output stream and the environment. See
170
+ # {Toys::Utils::Terminal.infer_styled}. Default is `nil`.
170
171
  #
171
172
  def initialize(help_flags: false,
172
173
  usage_flags: false,
@@ -25,6 +25,11 @@ module Toys
25
25
  # The arguments will be passed on to the
26
26
  # [HighLine constructor](https://www.rubydoc.info/gems/highline/HighLine:initialize).
27
27
  #
28
+ # Whether the HighLine object uses color is inferred from its output
29
+ # stream and the environment, using the same rule as a terminal. See
30
+ # {Toys::Utils::Terminal.infer_styled}. You can override it by setting
31
+ # `use_color` on the HighLine object.
32
+ #
28
33
  # **_Defined in the toys-core gem_**
29
34
  #
30
35
  module Highline
@@ -126,7 +126,6 @@ module Toys
126
126
  # * `:install` - just install the gem
127
127
  #
128
128
  # The default is `:confirm`.
129
- #
130
129
  # @param on_conflict [:error,:warn,:ignore] What to do if bundler has
131
130
  # already been run with a different Gemfile. Possible values:
132
131
  #
@@ -135,21 +134,30 @@ module Toys
135
134
  # * `:warn` - print a warning and proceed without bundling again
136
135
  #
137
136
  # The default is `:error`.
138
- #
139
137
  # @param default_confirm [boolean] The default confirmation result, if
140
138
  # `on_missing` is set to `:confirm`. Defaults to true.
141
139
  # @param terminal [Toys::Utils::Terminal] Terminal to use (optional)
142
140
  # @param input [IO] Input IO (optional, defaults to STDIN)
143
141
  # @param output [IO] Output IO (optional, defaults to STDOUT)
144
- # @param suppress_confirm [boolean] Deprecated. Use `on_missing` instead.
145
142
  #
146
143
  def initialize(on_missing: nil,
147
144
  on_conflict: nil,
145
+ default_confirm: nil,
148
146
  terminal: nil,
149
147
  input: nil,
150
- output: nil,
151
- suppress_confirm: nil,
152
- default_confirm: nil)
148
+ output: nil)
149
+ # Source available in the toys-core gem
150
+ end
151
+
152
+ ##
153
+ # Return a gem activator with the same settings as this one, except for
154
+ # the provided overrides. See the constructor for argument docs. If no
155
+ # non-nil overrides are provided, self is returned.
156
+ #
157
+ # @param overrides [Hash] Overrides. See the constructor for details.
158
+ # @return [Toys::Utils::Gems]
159
+ #
160
+ def with(**overrides)
153
161
  # Source available in the toys-core gem
154
162
  end
155
163
 
@@ -16,7 +16,9 @@ module Toys
16
16
  # Access a git cache.
17
17
  #
18
18
  # @param cache_dir [String] The path to the cache directory. Defaults to
19
- # a specific directory in the user's XDG cache.
19
+ # a specific directory in the user's XDG cache. Cache data is stored
20
+ # in a subdirectory named for the cache format version, so that clients
21
+ # using incompatible formats can share a cache directory safely.
20
22
  #
21
23
  def initialize(cache_dir: nil)
22
24
  # Source available in the toys-core gem
@@ -98,8 +100,9 @@ module Toys
98
100
  # repositories are requested, they will be reloaded from the remote
99
101
  # repository from scratch.
100
102
  #
101
- # Be careful not to remove repos that are currently in use by other
102
- # Toys::Utils::GitCache clients.
103
+ # This waits for any in-progress {#get} calls for these repos to finish.
104
+ # However, be careful not to remove repos whose shared sources are
105
+ # currently in use by other Toys::Utils::GitCache clients.
103
106
  #
104
107
  # @param remotes [Array<String>,:all,nil] The remotes to remove. If set
105
108
  # to :all or nil, removes all repos.
@@ -30,14 +30,18 @@ module Toys
30
30
  # stream. Default is `true`.
31
31
  # @param exec_service [Toys::Utils::Exec] The service to use for
32
32
  # executing commands, or `nil` (the default) to use a default.
33
+ # @param output [IO,StringIO,nil] The stream to which the pager process
34
+ # writes its output, and the default fallback stream. If `nil` (the
35
+ # default), the pager process inherits the parent's standard output.
33
36
  # @param fallback_io [IO] An IO-like object to write to if the pager is
34
- # disabled. Defaults to `$stdout`.
37
+ # disabled or could not be executed. Defaults to the `output` stream
38
+ # if one is given, otherwise `$stdout`.
35
39
  # @param rescue_broken_pipes [boolean] If `true` (the default), broken
36
40
  # pipes are silently rescued. This prevents the exception from
37
41
  # propagating out if the pager is interrupted. Set this parameter to
38
42
  # `false` to disable this behavior.
39
43
  #
40
- def initialize(command: true, exec_service: nil, fallback_io: nil,
44
+ def initialize(command: true, exec_service: nil, output: nil, fallback_io: nil,
41
45
  rescue_broken_pipes: true)
42
46
  # Source available in the toys-core gem
43
47
  end
@@ -71,12 +75,32 @@ module Toys
71
75
  #
72
76
  attr_accessor :command
73
77
 
78
+ ##
79
+ # The stream to which the pager process writes its output, or `nil` if
80
+ # the pager process inherits the parent's standard output.
81
+ #
82
+ # @return [IO,StringIO,nil]
83
+ #
84
+ attr_accessor :output
85
+
74
86
  ##
75
87
  # The IO stream used if the pager is disabled or could not be executed.
88
+ # If not set explicitly, this is the {#output} stream if one is set,
89
+ # otherwise `$stdout`.
76
90
  #
77
91
  # @return [IO]
78
92
  #
79
- attr_accessor :fallback_io
93
+ def fallback_io
94
+ # Source available in the toys-core gem
95
+ end
96
+
97
+ ##
98
+ # Set the IO stream used if the pager is disabled or could not be
99
+ # executed. Set to `nil` to use the default.
100
+ #
101
+ # @param value [IO,nil]
102
+ #
103
+ attr_writer :fallback_io
80
104
 
81
105
  class << self
82
106
  ##
@@ -91,8 +115,12 @@ module Toys
91
115
  # stream. Default is `true`.
92
116
  # @param exec_service [Toys::Utils::Exec] The service to use for
93
117
  # executing commands, or `nil` (the default) to use a default.
118
+ # @param output [IO,StringIO,nil] The stream to which the pager process
119
+ # writes its output, and the default fallback stream. If `nil` (the
120
+ # default), the pager process inherits the parent's standard output.
94
121
  # @param fallback_io [IO] An IO-like object to write to if the pager is
95
- # disabled. Defaults to `$stdout`.
122
+ # disabled or could not be executed. Defaults to the `output` stream
123
+ # if one is given, otherwise `$stdout`.
96
124
  # @param rescue_broken_pipes [boolean] If `true` (the default), broken
97
125
  # pipes are silently rescued. This prevents the exception from
98
126
  # propagating out if the pager is interrupted. Set this parameter to
@@ -107,6 +135,7 @@ module Toys
107
135
  #
108
136
  def start(command: true,
109
137
  exec_service: nil,
138
+ output: nil,
110
139
  fallback_io: nil,
111
140
  rescue_broken_pipes: true,
112
141
  &block)