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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -1
  3. data/README.md +2 -2
  4. data/builtins/system/tools.rb +1 -1
  5. data/lib/toys/templates/clean.rb +1 -1
  6. data/lib/toys/templates/gem_build.rb +1 -1
  7. data/lib/toys/templates/rubocop.rb +4 -1
  8. data/lib/toys/version.rb +1 -1
  9. metadata +8 -63
  10. data/core-docs/toys/acceptor.rb +0 -474
  11. data/core-docs/toys/arg_parser.rb +0 -397
  12. data/core-docs/toys/cli.rb +0 -466
  13. data/core-docs/toys/compat.rb +0 -2
  14. data/core-docs/toys/completion.rb +0 -340
  15. data/core-docs/toys/context.rb +0 -386
  16. data/core-docs/toys/core.rb +0 -14
  17. data/core-docs/toys/dsl/base.rb +0 -56
  18. data/core-docs/toys/dsl/flag.rb +0 -284
  19. data/core-docs/toys/dsl/flag_group.rb +0 -267
  20. data/core-docs/toys/dsl/internal.rb +0 -4
  21. data/core-docs/toys/dsl/positional_arg.rb +0 -155
  22. data/core-docs/toys/dsl/tool.rb +0 -1639
  23. data/core-docs/toys/errors.rb +0 -126
  24. data/core-docs/toys/flag.rb +0 -560
  25. data/core-docs/toys/flag_group.rb +0 -186
  26. data/core-docs/toys/input_file.rb +0 -17
  27. data/core-docs/toys/loader.rb +0 -363
  28. data/core-docs/toys/middleware.rb +0 -336
  29. data/core-docs/toys/mixin.rb +0 -142
  30. data/core-docs/toys/module_lookup.rb +0 -75
  31. data/core-docs/toys/positional_arg.rb +0 -145
  32. data/core-docs/toys/settings.rb +0 -524
  33. data/core-docs/toys/source_info.rb +0 -271
  34. data/core-docs/toys/standard_middleware/add_verbosity_flags.rb +0 -49
  35. data/core-docs/toys/standard_middleware/apply_config.rb +0 -24
  36. data/core-docs/toys/standard_middleware/handle_usage_errors.rb +0 -33
  37. data/core-docs/toys/standard_middleware/set_default_descriptions.rb +0 -222
  38. data/core-docs/toys/standard_middleware/show_help.rb +0 -190
  39. data/core-docs/toys/standard_middleware/show_root_version.rb +0 -45
  40. data/core-docs/toys/standard_mixins/bundler.rb +0 -98
  41. data/core-docs/toys/standard_mixins/exec.rb +0 -711
  42. data/core-docs/toys/standard_mixins/fileutils.rb +0 -18
  43. data/core-docs/toys/standard_mixins/gems.rb +0 -62
  44. data/core-docs/toys/standard_mixins/git_cache.rb +0 -41
  45. data/core-docs/toys/standard_mixins/highline.rb +0 -133
  46. data/core-docs/toys/standard_mixins/pager.rb +0 -50
  47. data/core-docs/toys/standard_mixins/terminal.rb +0 -135
  48. data/core-docs/toys/standard_mixins/xdg.rb +0 -49
  49. data/core-docs/toys/template.rb +0 -112
  50. data/core-docs/toys/tool_definition.rb +0 -1079
  51. data/core-docs/toys/utils/completion_engine.rb +0 -49
  52. data/core-docs/toys/utils/exec.rb +0 -776
  53. data/core-docs/toys/utils/gems.rb +0 -185
  54. data/core-docs/toys/utils/git_cache.rb +0 -353
  55. data/core-docs/toys/utils/help_text.rb +0 -134
  56. data/core-docs/toys/utils/pager.rb +0 -118
  57. data/core-docs/toys/utils/standard_ui.rb +0 -184
  58. data/core-docs/toys/utils/terminal.rb +0 -310
  59. data/core-docs/toys/utils/xdg.rb +0 -253
  60. data/core-docs/toys/wrappable_string.rb +0 -132
  61. data/core-docs/toys-core.rb +0 -111
@@ -1,253 +0,0 @@
1
- module Toys
2
- module Utils
3
- ##
4
- # **_Defined in the toys-core gem_**
5
- #
6
- # A class that provides tools for working with the XDG Base Directory
7
- # Specification.
8
- #
9
- # This class provides utility methods that locate base directories and
10
- # search paths for application state, configuration, caches, and other
11
- # data, according to the [XDG Base Directory Spec version
12
- # 0.8](https://specifications.freedesktop.org/basedir-spec/0.8/).
13
- #
14
- # Tools can use the `:xdg` mixin for convenient access to this class.
15
- #
16
- # ### Example
17
- #
18
- # require "toys/utils/xdg"
19
- #
20
- # xdg = Toys::Utils::XDG.new
21
- #
22
- # # Get config file paths, in order from most to least inportant
23
- # config_files = xdg.lookup_config("my-config.toml")
24
- # config_files.each { |path| read_my_config(path) }
25
- #
26
- # ### Windows operation
27
- #
28
- # The Spec assumes a unix-like environment, and cannot be applied directly
29
- # to Windows without modification. In general, this class will function on
30
- # Windows, but with the following caveats:
31
- #
32
- # * All file paths must use Windows-style absolute paths, beginning with
33
- # the drive letter.
34
- # * Environment variables that can contain multiple paths (`XDG_*_DIRS`)
35
- # use the Windows path delimiter (`;`) rather than the unix path
36
- # delimiter (`:`).
37
- # * Defaults for home directories (`XDG_*_HOME`) will follow unix
38
- # conventions, using subdirectories under the user's profile directory
39
- # rather than the Windows known folder paths.
40
- # * Defaults for search paths (`XDG_*_DIRS`) will be empty and will not
41
- # use the Windows known folder paths.
42
- #
43
- class XDG
44
- ##
45
- # Create an instance of XDG.
46
- #
47
- # @param env [Hash{String=>String}] the environment variables. Normally,
48
- # you can omit this argument, as it will default to `::ENV`.
49
- #
50
- def initialize(env: ::ENV)
51
- # Source available in the toys-core gem
52
- end
53
-
54
- ##
55
- # Returns the absolute path to the current user's home directory.
56
- #
57
- # @return [String]
58
- #
59
- def home_dir
60
- # Source available in the toys-core gem
61
- end
62
-
63
- ##
64
- # Returns the absolute path to the single base directory relative to
65
- # which user-specific data files should be written.
66
- # Corresponds to the value of the `$XDG_DATA_HOME` environment variable
67
- # and its defaults according to the XDG Base Directory Spec.
68
- #
69
- # @return [String]
70
- #
71
- def data_home
72
- # Source available in the toys-core gem
73
- end
74
-
75
- ##
76
- # Returns the absolute path to the single base directory relative to
77
- # which user-specific configuration files should be written.
78
- # Corresponds to the value of the `$XDG_CONFIG_HOME` environment variable
79
- # and its defaults according to the XDG Base Directory Spec.
80
- #
81
- # @return [String]
82
- #
83
- def config_home
84
- # Source available in the toys-core gem
85
- end
86
-
87
- ##
88
- # Returns the absolute path to the single base directory relative to
89
- # which user-specific state files should be written.
90
- # Corresponds to the value of the `$XDG_STATE_HOME` environment variable
91
- # and its defaults according to the XDG Base Directory Spec.
92
- #
93
- # @return [String]
94
- #
95
- def state_home
96
- # Source available in the toys-core gem
97
- end
98
-
99
- ##
100
- # Returns the absolute path to the single base directory relative to
101
- # which user-specific non-essential (cached) data should be written.
102
- # Corresponds to the value of the `$XDG_CACHE_HOME` environment variable
103
- # and its defaults according to the XDG Base Directory Spec.
104
- #
105
- # @return [String]
106
- #
107
- def cache_home
108
- # Source available in the toys-core gem
109
- end
110
-
111
- ##
112
- # Returns the absolute path to the single base directory relative to
113
- # which user-specific executable files may be written.
114
- # Returns the value of `$HOME/.local/bin` as specified by the XDG Base
115
- # Directory Spec.
116
- #
117
- # @return [String]
118
- #
119
- def executable_home
120
- # Source available in the toys-core gem
121
- end
122
-
123
- ##
124
- # Returns the set of preference ordered base directories relative to
125
- # which data files should be searched, as an array of absolute paths.
126
- # The array is ordered from most to least important, and does _not_
127
- # include the data home directory.
128
- # Corresponds to the value of the `$XDG_DATA_DIRS` environment variable
129
- # and its defaults according to the XDG Base Directory Spec.
130
- #
131
- # @return [Array<String>]
132
- #
133
- def data_dirs
134
- # Source available in the toys-core gem
135
- end
136
-
137
- ##
138
- # Returns the set of preference ordered base directories relative to
139
- # which configuration files should be searched, as an array of absolute
140
- # paths. The array is ordered from most to least important, and does
141
- # _not_ include the config home directory.
142
- # Corresponds to the value of the `$XDG_CONFIG_DIRS` environment variable
143
- # and its defaults according to the XDG Base Directory Spec.
144
- #
145
- # @return [Array<String>]
146
- #
147
- def config_dirs
148
- # Source available in the toys-core gem
149
- end
150
-
151
- ##
152
- # Returns the absolute path to the single base directory relative to
153
- # which user-specific runtime files and other file objects should be
154
- # placed. May return `nil` if no such directory could be determined.
155
- #
156
- # @return [String,nil]
157
- #
158
- def runtime_dir
159
- # Source available in the toys-core gem
160
- end
161
-
162
- ##
163
- # Searches the data directories for an object with the given relative
164
- # path, and returns an array of absolute paths to all objects found in
165
- # the data directories (i.e. in {#data_dirs} or {#data_home}), in order
166
- # from most to least important.
167
- #
168
- # @param path [String] Relative path of the object to search for
169
- # @param type [String,Symbol,Array<String,Symbol>] The type(s) of objects
170
- # to find. You can specify any of the types defined by
171
- # [File::Stat#ftype](https://ruby-doc.org/core/File/Stat.html#method-i-ftype),
172
- # such as `file` or `directory`, or the special type `any`. Types can
173
- # be specified as strings or the corresponding symbols. If this
174
- # argument is not provided, the default of `file` is used.
175
- # @return [Array<String>]
176
- #
177
- def lookup_data(path, type: :file)
178
- # Source available in the toys-core gem
179
- end
180
-
181
- ##
182
- # Searches the config directories for an object with the given relative
183
- # path, and returns an array of absolute paths to all objects found in
184
- # the config directories (i.e. in {#config_dirs} or {#config_home}), in
185
- # order from most to least important.
186
- #
187
- # @param path [String] Relative path of the object to search for
188
- # @param type [String,Symbol,Array<String,Symbol>] The type(s) of objects
189
- # to find. You can specify any of the types defined by
190
- # [File::Stat#ftype](https://ruby-doc.org/core/File/Stat.html#method-i-ftype),
191
- # such as `file` or `directory`, or the special type `any`. Types can
192
- # be specified as strings or the corresponding symbols. If this
193
- # argument is not provided, the default of `file` is used.
194
- # @return [Array<String>]
195
- #
196
- def lookup_config(path, type: :file)
197
- # Source available in the toys-core gem
198
- end
199
-
200
- ##
201
- # Returns the absolute path to a directory under {#data_home}, creating
202
- # it if it doesn't already exist.
203
- #
204
- # @param path [String] The relative path to the subdir within the base
205
- # data directory.
206
- # @return [String] The absolute path to the subdir.
207
- # @raise [Errno::EEXIST] If a non-directory already exists there
208
- #
209
- def ensure_data_subdir(path)
210
- # Source available in the toys-core gem
211
- end
212
-
213
- ##
214
- # Returns the absolute path to a directory under {#config_home}, creating
215
- # it if it doesn't already exist.
216
- #
217
- # @param path [String] The relative path to the subdir within the base
218
- # config directory.
219
- # @return [String] The absolute path to the subdir.
220
- # @raise [Errno::EEXIST] If a non-directory already exists there
221
- #
222
- def ensure_config_subdir(path)
223
- # Source available in the toys-core gem
224
- end
225
-
226
- ##
227
- # Returns the absolute path to a directory under {#state_home}, creating
228
- # it if it doesn't already exist.
229
- #
230
- # @param path [String] The relative path to the subdir within the base
231
- # state directory.
232
- # @return [String] The absolute path to the subdir.
233
- # @raise [Errno::EEXIST] If a non-directory already exists there
234
- #
235
- def ensure_state_subdir(path)
236
- # Source available in the toys-core gem
237
- end
238
-
239
- ##
240
- # Returns the absolute path to a directory under {#cache_home}, creating
241
- # it if it doesn't already exist.
242
- #
243
- # @param path [String] The relative path to the subdir within the base
244
- # cache directory.
245
- # @return [String] The absolute path to the subdir.
246
- # @raise [Errno::EEXIST] If a non-directory already exists there
247
- #
248
- def ensure_cache_subdir(path)
249
- # Source available in the toys-core gem
250
- end
251
- end
252
- end
253
- end
@@ -1,132 +0,0 @@
1
- module Toys
2
- ##
3
- # **_Defined in the toys-core gem_**
4
- #
5
- # A string intended for word-wrapped display.
6
- #
7
- # A WrappableString is an array of string "fragments" representing the atomic
8
- # units that should not be split when word-wrapping. It should be possible to
9
- # reconstruct the original string by joining these fragments with whitespace.
10
- #
11
- class WrappableString
12
- ##
13
- # Create a wrapped string.
14
- #
15
- # You can pass either:
16
- #
17
- # * A single String, which will be split into fragments by whitespace.
18
- # * An array of Strings representing the fragments explicitly.
19
- #
20
- # @param string [String,Array<String>] The string or array of string
21
- # fragments
22
- #
23
- def initialize(string = "")
24
- # Source available in the toys-core gem
25
- end
26
-
27
- ##
28
- # Returns the string fragments, i.e. the individual "words" for wrapping.
29
- #
30
- # @return [Array<String>]
31
- #
32
- attr_reader :fragments
33
-
34
- ##
35
- # Returns a new WrappaableString whose content is the concatenation of this
36
- # WrappableString with another WrappableString.
37
- #
38
- # @param other [WrappableString]
39
- # @return [WrappableString]
40
- #
41
- def +(other)
42
- # Source available in the toys-core gem
43
- end
44
-
45
- ##
46
- # Returns true if the string is empty (i.e. has no fragments)
47
- #
48
- # @return [Boolean]
49
- #
50
- def empty?
51
- # Source available in the toys-core gem
52
- end
53
-
54
- ##
55
- # Returns the string without any wrapping
56
- #
57
- # @return [String]
58
- #
59
- def string
60
- # Source available in the toys-core gem
61
- end
62
- alias to_s string
63
-
64
- ##
65
- # Tests two wrappable strings for equality
66
- # @param other [Object]
67
- # @return [Boolean]
68
- #
69
- def ==(other)
70
- # Source available in the toys-core gem
71
- end
72
- alias eql? ==
73
-
74
- ##
75
- # Returns a hash code for this object
76
- # @return [Integer]
77
- #
78
- def hash
79
- # Source available in the toys-core gem
80
- end
81
-
82
- ##
83
- # Wraps the string to the given width.
84
- #
85
- # @param width [Integer,nil] Width in characters, or `nil` for infinite.
86
- # @param width2 [Integer,nil] Width in characters for the second and
87
- # subsequent lines, or `nil` to use the same as width.
88
- #
89
- # @return [Array<String>] Wrapped lines
90
- #
91
- def wrap(width, width2 = nil)
92
- # Source available in the toys-core gem
93
- end
94
-
95
- ##
96
- # Wraps an array of lines to the given width.
97
- #
98
- # @param strs [Array<WrappableString>] Array of strings to wrap.
99
- # @param width [Integer,nil] Width in characters, or `nil` for infinite.
100
- # @param width2 [Integer,nil] Width in characters for the second and
101
- # subsequent lines, or `nil` to use the same as width.
102
- #
103
- # @return [Array<String>] Wrapped lines
104
- #
105
- def self.wrap_lines(strs, width, width2 = nil)
106
- # Source available in the toys-core gem
107
- end
108
-
109
- ##
110
- # Make the given object a WrappableString.
111
- # If the object is already a WrappableString, return it. Otherwise,
112
- # treat it as a string or an array of strings and wrap it in a
113
- # WrappableString.
114
- #
115
- # @param obj [Toys::WrappableString,String,Array<String>]
116
- # @return [Toys::WrappableString]
117
- #
118
- def self.make(obj)
119
- # Source available in the toys-core gem
120
- end
121
-
122
- ##
123
- # Make the given object an array of WrappableString.
124
- #
125
- # @param objs [Array<Toys::WrappableString,String,Array<String>>]
126
- # @return [Array<Toys::WrappableString>]
127
- #
128
- def self.make_array(objs)
129
- # Source available in the toys-core gem
130
- end
131
- end
132
- end
@@ -1,111 +0,0 @@
1
- ##
2
- # **_Defined in the toys-core gem_**
3
- #
4
- # Toys is a configurable command line tool. Write commands in config files
5
- # using a simple DSL, and Toys will provide the command line executable and
6
- # take care of all the details such as argument parsing, online help, and error
7
- # reporting. Toys is designed for software developers, IT professionals, and
8
- # other power users who want to write and organize scripts to automate their
9
- # workflows. It can also be used as a Rake replacement, providing a more
10
- # natural command line interface for your project's build tasks.
11
- #
12
- # This module contains the command line framework underlying Toys. It can be
13
- # used to create command line executables using the Toys DSL and classes.
14
- #
15
- # ## Common starting points
16
- #
17
- # Some of the most commonly needed class documentation is listed below:
18
- #
19
- # * For information on the DSL used to write tools, start with
20
- # {Toys::DSL::Tool}.
21
- # * The base class for tool runtime (i.e. that defines the basic methods
22
- # available to a tool's implementation) is {Toys::Context}.
23
- # * For information on writing mixins, see {Toys::Mixin}.
24
- # * For information on writing templates, see {Toys::Template}.
25
- # * For information on writing acceptors, see {Toys::Acceptor}.
26
- # * For information on writing custom shell completions, see {Toys::Completion}.
27
- # * Standard mixins are defined under the {Toys::StandardMixins} module.
28
- # * Various utilities are defined under {Toys::Utils}. Some of these serve as
29
- # the implementations of corresponding mixins.
30
- # * The main entrypoint for the command line framework is {Toys::CLI}.
31
- #
32
- # Other important internal classes are listed below.
33
- #
34
- # * The definition of a tool is represented by {Toys::ToolDefinition} along
35
- # the helpers {Toys::Flag}, {Toys::PositionalArg}, and {Toys::FlagGroup}.
36
- # * Argument parsing is implemented by {Toys::ArgParser}.
37
- # * The process of finding and loading a tool definition given a tool name, is
38
- # implemented by {Toys::Loader}.
39
- # * Text wrapping is handled by {Toys::WrappableString}.
40
- # * The settings system is implemented by {Toys::Settings}.
41
- #
42
- module Toys
43
- ##
44
- # **_Defined in the toys-core gem_**
45
- #
46
- # Namespace for DSL classes. These classes provide the directives that can be
47
- # used in configuration files.
48
- #
49
- # DSL directives that can appear at the top level of Toys files and tool
50
- # blocks are defined by the {Toys::DSL::Tool} module.
51
- #
52
- # Directives that can appear within a block passed to {Toys::DSL::Tool#flag}
53
- # are defined by the {Toys::DSL::Flag} class.
54
- #
55
- # Directives that can appear within a {Toys::DSL::Tool#flag_group} block or
56
- # any of its related directives, are defined by the {Toys::DSL::FlagGroup}
57
- # class.
58
- #
59
- # Directives that can appear within a {Toys::DSL::Tool#required_arg},
60
- # {Toys::DSL::Tool#optional_arg}, or {Toys::DSL::Tool#remaining_args} block,
61
- # are defined by the {Toys::DSL::PositionalArg} class.
62
- #
63
- module DSL
64
- end
65
-
66
- ##
67
- # **_Defined in the toys-core gem_**
68
- #
69
- # Namespace for standard middleware classes.
70
- #
71
- # These middleware are provided by Toys-Core and can be referenced by name
72
- # when creating a {Toys::CLI}.
73
- #
74
- module StandardMiddleware
75
- end
76
-
77
- ##
78
- # **_Defined in the toys-core gem_**
79
- #
80
- # Namespace for standard mixin classes.
81
- #
82
- # These mixins are provided by Toys-Core and can be included by name by
83
- # passing a symbol to {Toys::DSL::Tool#include}.
84
- #
85
- module StandardMixins
86
- end
87
-
88
- ##
89
- # **_Defined in the toys-core gem_**
90
- #
91
- # Namespace for common utility classes.
92
- #
93
- # These classes are not loaded by default, and must be required explicitly.
94
- # For example, before using {Toys::Utils::Exec}, you must:
95
- #
96
- # require "toys/utils/exec"
97
- #
98
- module Utils
99
- end
100
-
101
- class << self
102
- ##
103
- # Path to the executable. This can, for example, be invoked to run a subtool
104
- # in a clean environment.
105
- #
106
- # @return [String] if there is an executable
107
- # @return [nil] if there is no such executable
108
- #
109
- attr_accessor :executable_path
110
- end
111
- end