gorails 0.1.1 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -1
- data/Gemfile.lock +1 -6
- data/README.md +41 -12
- data/bin/update-deps +95 -0
- data/exe/gorails +2 -1
- data/gorails.gemspec +0 -2
- data/lib/gorails/commands/railsbytes.rb +45 -4
- data/lib/gorails/commands/version.rb +15 -0
- data/lib/gorails/commands.rb +2 -5
- data/lib/gorails/version.rb +1 -1
- data/lib/gorails.rb +11 -20
- data/vendor/deps/cli-kit/REVISION +1 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/definition.rb +301 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/evaluation.rb +237 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/parser/node.rb +131 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/parser.rb +128 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/tokenizer.rb +132 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args.rb +15 -0
- data/vendor/deps/cli-kit/lib/cli/kit/base_command.rb +29 -0
- data/vendor/deps/cli-kit/lib/cli/kit/command_help.rb +256 -0
- data/vendor/deps/cli-kit/lib/cli/kit/command_registry.rb +141 -0
- data/vendor/deps/cli-kit/lib/cli/kit/config.rb +137 -0
- data/vendor/deps/cli-kit/lib/cli/kit/core_ext.rb +30 -0
- data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +165 -0
- data/vendor/deps/cli-kit/lib/cli/kit/executor.rb +99 -0
- data/vendor/deps/cli-kit/lib/cli/kit/ini.rb +94 -0
- data/vendor/deps/cli-kit/lib/cli/kit/levenshtein.rb +89 -0
- data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +95 -0
- data/vendor/deps/cli-kit/lib/cli/kit/opts.rb +284 -0
- data/vendor/deps/cli-kit/lib/cli/kit/resolver.rb +67 -0
- data/vendor/deps/cli-kit/lib/cli/kit/sorbet_runtime_stub.rb +142 -0
- data/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +253 -0
- data/vendor/deps/cli-kit/lib/cli/kit/support.rb +10 -0
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +350 -0
- data/vendor/deps/cli-kit/lib/cli/kit/util.rb +133 -0
- data/vendor/deps/cli-kit/lib/cli/kit/version.rb +7 -0
- data/vendor/deps/cli-kit/lib/cli/kit.rb +151 -0
- data/vendor/deps/cli-ui/REVISION +1 -0
- data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +180 -0
- data/vendor/deps/cli-ui/lib/cli/ui/color.rb +98 -0
- data/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +216 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +116 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +176 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +149 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +112 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +300 -0
- data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +92 -0
- data/vendor/deps/cli-ui/lib/cli/ui/os.rb +58 -0
- data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +72 -0
- data/vendor/deps/cli-ui/lib/cli/ui/progress.rb +102 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +534 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +36 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +354 -0
- data/vendor/deps/cli-ui/lib/cli/ui/sorbet_runtime_stub.rb +143 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb +46 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +292 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +82 -0
- data/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +264 -0
- data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +53 -0
- data/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +107 -0
- data/vendor/deps/cli-ui/lib/cli/ui/version.rb +6 -0
- data/vendor/deps/cli-ui/lib/cli/ui/widgets/base.rb +37 -0
- data/vendor/deps/cli-ui/lib/cli/ui/widgets/status.rb +75 -0
- data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +91 -0
- data/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +63 -0
- data/vendor/deps/cli-ui/lib/cli/ui.rb +356 -0
- metadata +59 -30
@@ -0,0 +1,95 @@
|
|
1
|
+
# typed: true
|
2
|
+
require 'cli/kit'
|
3
|
+
require 'logger'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
module CLI
|
7
|
+
module Kit
|
8
|
+
class Logger
|
9
|
+
extend T::Sig
|
10
|
+
|
11
|
+
MAX_LOG_SIZE = 5 * 1024 * 1000 # 5MB
|
12
|
+
MAX_NUM_LOGS = 10
|
13
|
+
|
14
|
+
# Constructor for CLI::Kit::Logger
|
15
|
+
#
|
16
|
+
# @param debug_log_file [String] path to the file where debug logs should be stored
|
17
|
+
sig { params(debug_log_file: String, env_debug_name: String).void }
|
18
|
+
def initialize(debug_log_file:, env_debug_name: 'DEBUG')
|
19
|
+
FileUtils.mkpath(File.dirname(debug_log_file))
|
20
|
+
@debug_logger = ::Logger.new(debug_log_file, MAX_NUM_LOGS, MAX_LOG_SIZE)
|
21
|
+
@env_debug_name = env_debug_name
|
22
|
+
end
|
23
|
+
|
24
|
+
# Functionally equivalent to Logger#info
|
25
|
+
# Also logs to the debug file, taking into account CLI::UI::StdoutRouter.current_id
|
26
|
+
#
|
27
|
+
# @param msg [String] the message to log
|
28
|
+
# @param debug [Boolean] determines if the debug logger will receive the log (default true)
|
29
|
+
sig { params(msg: String, debug: T::Boolean).void }
|
30
|
+
def info(msg, debug: true)
|
31
|
+
$stdout.puts CLI::UI.fmt(msg)
|
32
|
+
@debug_logger.info(format_debug(msg)) if debug
|
33
|
+
end
|
34
|
+
|
35
|
+
# Functionally equivalent to Logger#warn
|
36
|
+
# Also logs to the debug file, taking into account CLI::UI::StdoutRouter.current_id
|
37
|
+
#
|
38
|
+
# @param msg [String] the message to log
|
39
|
+
# @param debug [Boolean] determines if the debug logger will receive the log (default true)
|
40
|
+
sig { params(msg: String, debug: T::Boolean).void }
|
41
|
+
def warn(msg, debug: true)
|
42
|
+
$stdout.puts CLI::UI.fmt("{{yellow:#{msg}}}")
|
43
|
+
@debug_logger.warn(format_debug(msg)) if debug
|
44
|
+
end
|
45
|
+
|
46
|
+
# Functionally equivalent to Logger#error
|
47
|
+
# Also logs to the debug file, taking into account CLI::UI::StdoutRouter.current_id
|
48
|
+
#
|
49
|
+
# @param msg [String] the message to log
|
50
|
+
# @param debug [Boolean] determines if the debug logger will receive the log (default true)
|
51
|
+
sig { params(msg: String, debug: T::Boolean).void }
|
52
|
+
def error(msg, debug: true)
|
53
|
+
$stderr.puts CLI::UI.fmt("{{red:#{msg}}}")
|
54
|
+
@debug_logger.error(format_debug(msg)) if debug
|
55
|
+
end
|
56
|
+
|
57
|
+
# Functionally equivalent to Logger#fatal
|
58
|
+
# Also logs to the debug file, taking into account CLI::UI::StdoutRouter.current_id
|
59
|
+
#
|
60
|
+
# @param msg [String] the message to log
|
61
|
+
# @param debug [Boolean] determines if the debug logger will receive the log (default true)
|
62
|
+
sig { params(msg: String, debug: T::Boolean).void }
|
63
|
+
def fatal(msg, debug: true)
|
64
|
+
$stderr.puts CLI::UI.fmt("{{red:{{bold:Fatal:}} #{msg}}}")
|
65
|
+
@debug_logger.fatal(format_debug(msg)) if debug
|
66
|
+
end
|
67
|
+
|
68
|
+
# Similar to Logger#debug, however will not output to STDOUT unless DEBUG env var is set
|
69
|
+
# Logs to the debug file, taking into account CLI::UI::StdoutRouter.current_id
|
70
|
+
#
|
71
|
+
# @param msg [String] the message to log
|
72
|
+
sig { params(msg: String).void }
|
73
|
+
def debug(msg)
|
74
|
+
$stdout.puts CLI::UI.fmt(msg) if debug?
|
75
|
+
@debug_logger.debug(format_debug(msg))
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
sig { params(msg: String).returns(String) }
|
81
|
+
def format_debug(msg)
|
82
|
+
msg = CLI::UI.fmt(msg)
|
83
|
+
return msg unless CLI::UI::StdoutRouter.current_id
|
84
|
+
|
85
|
+
"[#{CLI::UI::StdoutRouter.current_id&.fetch(:id, nil)}] #{msg}"
|
86
|
+
end
|
87
|
+
|
88
|
+
sig { returns(T::Boolean) }
|
89
|
+
def debug?
|
90
|
+
val = ENV[@env_debug_name]
|
91
|
+
!!val && val != '0' && val != ''
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,284 @@
|
|
1
|
+
# typed: true
|
2
|
+
require 'cli/kit'
|
3
|
+
|
4
|
+
module CLI
|
5
|
+
module Kit
|
6
|
+
class Opts
|
7
|
+
extend T::Sig
|
8
|
+
|
9
|
+
module Mixin
|
10
|
+
extend T::Sig
|
11
|
+
include Kernel
|
12
|
+
|
13
|
+
module MixinClassMethods
|
14
|
+
extend T::Sig
|
15
|
+
|
16
|
+
sig { params(included_module: Module).void }
|
17
|
+
def include(included_module)
|
18
|
+
super
|
19
|
+
return unless included_module.is_a?(MixinClassMethods)
|
20
|
+
|
21
|
+
included_module.tracked_methods.each { |m| track_method(m) }
|
22
|
+
end
|
23
|
+
|
24
|
+
# No signature - Sorbet uses method_added internally, so can't verify it
|
25
|
+
def method_added(method_name) # rubocop:disable Sorbet/EnforceSignatures
|
26
|
+
super
|
27
|
+
track_method(method_name)
|
28
|
+
end
|
29
|
+
|
30
|
+
sig { params(method_name: Symbol).void }
|
31
|
+
def track_method(method_name)
|
32
|
+
@tracked_methods ||= []
|
33
|
+
@tracked_methods << method_name unless @tracked_methods.include?(method_name)
|
34
|
+
end
|
35
|
+
|
36
|
+
sig { returns(T::Array[Symbol]) }
|
37
|
+
def tracked_methods
|
38
|
+
@tracked_methods || []
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
sig { params(klass: Module).void }
|
43
|
+
def self.included(klass)
|
44
|
+
klass.extend(MixinClassMethods)
|
45
|
+
end
|
46
|
+
|
47
|
+
sig do
|
48
|
+
params(
|
49
|
+
name: Symbol,
|
50
|
+
short: T.nilable(String),
|
51
|
+
long: T.nilable(String),
|
52
|
+
desc: T.nilable(String),
|
53
|
+
default: T.any(NilClass, String, T.proc.returns(String)),
|
54
|
+
).returns(T.nilable(String))
|
55
|
+
end
|
56
|
+
def option(name: infer_name, short: nil, long: nil, desc: nil, default: nil)
|
57
|
+
unless default.nil?
|
58
|
+
raise(ArgumentError, 'declare options with non-nil defaults using `option!` instead of `option`')
|
59
|
+
end
|
60
|
+
|
61
|
+
case @obj
|
62
|
+
when Args::Definition
|
63
|
+
@obj.add_option(
|
64
|
+
name, short: short, long: long, desc: desc, default: default,
|
65
|
+
)
|
66
|
+
'(result unavailable)'
|
67
|
+
when Args::Evaluation
|
68
|
+
@obj.opt.send(name)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
sig do
|
73
|
+
params(
|
74
|
+
name: Symbol,
|
75
|
+
short: T.nilable(String),
|
76
|
+
long: T.nilable(String),
|
77
|
+
desc: T.nilable(String),
|
78
|
+
default: T.any(NilClass, String, T.proc.returns(String)),
|
79
|
+
).returns(String)
|
80
|
+
end
|
81
|
+
def option!(name: infer_name, short: nil, long: nil, desc: nil, default: nil)
|
82
|
+
case @obj
|
83
|
+
when Args::Definition
|
84
|
+
@obj.add_option(
|
85
|
+
name, short: short, long: long, desc: desc, default: default,
|
86
|
+
)
|
87
|
+
'(result unavailable)'
|
88
|
+
when Args::Evaluation
|
89
|
+
@obj.opt.send(name)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
sig do
|
94
|
+
params(
|
95
|
+
name: Symbol,
|
96
|
+
short: T.nilable(String),
|
97
|
+
long: T.nilable(String),
|
98
|
+
desc: T.nilable(String),
|
99
|
+
).returns(T::Array[String])
|
100
|
+
end
|
101
|
+
def multi_option(name: infer_name, short: nil, long: nil, desc: nil)
|
102
|
+
case @obj
|
103
|
+
when Args::Definition
|
104
|
+
@obj.add_option(
|
105
|
+
name, short: short, long: long, desc: desc, multi: true,
|
106
|
+
)
|
107
|
+
['(result unavailable)']
|
108
|
+
when Args::Evaluation
|
109
|
+
@obj.opt.send(name)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
sig do
|
114
|
+
params(
|
115
|
+
name: Symbol,
|
116
|
+
short: T.nilable(String),
|
117
|
+
long: T.nilable(String),
|
118
|
+
desc: T.nilable(String),
|
119
|
+
).returns(T::Boolean)
|
120
|
+
end
|
121
|
+
def flag(name: infer_name, short: nil, long: nil, desc: nil)
|
122
|
+
case @obj
|
123
|
+
when Args::Definition
|
124
|
+
@obj.add_flag(name, short: short, long: long, desc: desc)
|
125
|
+
false
|
126
|
+
when Args::Evaluation
|
127
|
+
@obj.flag.send(name)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
sig { params(name: Symbol, desc: T.nilable(String)).returns(String) }
|
132
|
+
def position!(name: infer_name, desc: nil)
|
133
|
+
case @obj
|
134
|
+
when Args::Definition
|
135
|
+
@obj.add_position(name, desc: desc, required: true, multiple: false)
|
136
|
+
'(result unavailable)'
|
137
|
+
when Args::Evaluation
|
138
|
+
@obj.position.send(name)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
sig { params(name: Symbol, desc: T.nilable(String)).returns(T.nilable(String)) }
|
143
|
+
def position(name: infer_name, desc: nil)
|
144
|
+
case @obj
|
145
|
+
when Args::Definition
|
146
|
+
@obj.add_position(name, desc: desc, required: false, multiple: false)
|
147
|
+
'(result unavailable)'
|
148
|
+
when Args::Evaluation
|
149
|
+
@obj.position.send(name)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
sig { params(name: Symbol, desc: T.nilable(String)).returns(T::Array[String]) }
|
154
|
+
def rest(name: infer_name, desc: nil)
|
155
|
+
case @obj
|
156
|
+
when Args::Definition
|
157
|
+
@obj.add_position(name, desc: desc, required: false, multiple: true)
|
158
|
+
['(result unavailable)']
|
159
|
+
when Args::Evaluation
|
160
|
+
@obj.position.send(name)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
private
|
165
|
+
|
166
|
+
sig { returns(Symbol) }
|
167
|
+
def infer_name
|
168
|
+
to_skip = 1
|
169
|
+
Kernel.caller_locations&.each do |loc|
|
170
|
+
next if loc.path =~ /sorbet-runtime/
|
171
|
+
|
172
|
+
if to_skip > 0
|
173
|
+
to_skip -= 1
|
174
|
+
next
|
175
|
+
end
|
176
|
+
return(T.must(loc.label&.to_sym))
|
177
|
+
end
|
178
|
+
raise(ArgumentError, 'could not infer name')
|
179
|
+
end
|
180
|
+
end
|
181
|
+
include(Mixin)
|
182
|
+
|
183
|
+
DEFAULT_OPTIONS = [:helpflag]
|
184
|
+
|
185
|
+
sig { returns(T::Boolean) }
|
186
|
+
def helpflag
|
187
|
+
flag(name: :help, short: '-h', long: '--help', desc: 'Show this help message')
|
188
|
+
end
|
189
|
+
|
190
|
+
sig { params(obj: T.any(Args::Definition, Args::Evaluation)).void }
|
191
|
+
def initialize(obj)
|
192
|
+
@obj = obj
|
193
|
+
end
|
194
|
+
|
195
|
+
sig { returns(T::Array[String]) }
|
196
|
+
def unparsed
|
197
|
+
obj = assert_result!
|
198
|
+
obj.unparsed
|
199
|
+
end
|
200
|
+
|
201
|
+
sig do
|
202
|
+
params(
|
203
|
+
block: T.nilable(
|
204
|
+
T.proc.params(arg0: Symbol, arg1: T.nilable(String)).void,
|
205
|
+
),
|
206
|
+
).returns(T.untyped)
|
207
|
+
end
|
208
|
+
def each_option(&block)
|
209
|
+
return(enum_for(:each_option)) unless block_given?
|
210
|
+
|
211
|
+
obj = assert_result!
|
212
|
+
obj.defn.options.each do |opt|
|
213
|
+
name = opt.name
|
214
|
+
value = obj.opt.send(name)
|
215
|
+
yield(name, value)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
sig do
|
220
|
+
params(
|
221
|
+
block: T.nilable(
|
222
|
+
T.proc.params(arg0: Symbol, arg1: T::Boolean).void,
|
223
|
+
),
|
224
|
+
).returns(T.untyped)
|
225
|
+
end
|
226
|
+
def each_flag(&block)
|
227
|
+
return(enum_for(:each_flag)) unless block_given?
|
228
|
+
|
229
|
+
obj = assert_result!
|
230
|
+
obj.defn.flags.each do |flag|
|
231
|
+
name = flag.name
|
232
|
+
value = obj.flag.send(name)
|
233
|
+
yield(name, value)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
sig { params(name: String).returns(T.nilable(T.any(String, T::Boolean))) }
|
238
|
+
def [](name)
|
239
|
+
obj = assert_result!
|
240
|
+
if obj.opt.respond_to?(name)
|
241
|
+
obj.opt.send(name)
|
242
|
+
elsif obj.flag.respond_to?(name)
|
243
|
+
obj.flag.send(name)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
sig { params(name: String).returns(T.nilable(String)) }
|
248
|
+
def lookup_option(name)
|
249
|
+
obj = assert_result!
|
250
|
+
obj.opt.send(name)
|
251
|
+
rescue NoMethodError
|
252
|
+
# TODO: should we raise a KeyError?
|
253
|
+
nil
|
254
|
+
end
|
255
|
+
|
256
|
+
sig { params(name: String).returns(T::Boolean) }
|
257
|
+
def lookup_flag(name)
|
258
|
+
obj = assert_result!
|
259
|
+
obj.flag.send(name)
|
260
|
+
rescue NoMethodError
|
261
|
+
false
|
262
|
+
end
|
263
|
+
|
264
|
+
sig { returns(Args::Evaluation) }
|
265
|
+
def assert_result!
|
266
|
+
raise(NotImplementedError, 'not implemented') if @obj.is_a?(Args::Definition)
|
267
|
+
|
268
|
+
@obj
|
269
|
+
end
|
270
|
+
|
271
|
+
sig { void }
|
272
|
+
def install_to_definition
|
273
|
+
raise('not a Definition') unless @obj.is_a?(Args::Definition)
|
274
|
+
|
275
|
+
T.cast(self.class, Mixin::MixinClassMethods).tracked_methods.each do |m|
|
276
|
+
send(m)
|
277
|
+
end
|
278
|
+
DEFAULT_OPTIONS.each do |m|
|
279
|
+
send(m)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# typed: true
|
2
|
+
require 'cli/kit'
|
3
|
+
|
4
|
+
module CLI
|
5
|
+
module Kit
|
6
|
+
class Resolver
|
7
|
+
extend T::Sig
|
8
|
+
|
9
|
+
sig { params(tool_name: String, command_registry: CLI::Kit::CommandRegistry).void }
|
10
|
+
def initialize(tool_name:, command_registry:)
|
11
|
+
@tool_name = tool_name
|
12
|
+
@command_registry = command_registry
|
13
|
+
end
|
14
|
+
|
15
|
+
sig { params(args: T::Array[String]).returns([T.class_of(CLI::Kit::BaseCommand), String, T::Array[String]]) }
|
16
|
+
def call(args)
|
17
|
+
args = args.dup
|
18
|
+
command_name = args.shift
|
19
|
+
|
20
|
+
command, resolved_name = @command_registry.lookup_command(command_name)
|
21
|
+
|
22
|
+
if command.nil?
|
23
|
+
command_not_found(command_name)
|
24
|
+
raise CLI::Kit::AbortSilent # Already output message
|
25
|
+
end
|
26
|
+
|
27
|
+
[command, resolved_name, args]
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
sig { params(name: T.nilable(String)).void }
|
33
|
+
def command_not_found(name)
|
34
|
+
CLI::UI::Frame.open('Command not found', color: :red, timing: false) do
|
35
|
+
$stderr.puts(CLI::UI.fmt("{{command:#{@tool_name} #{name}}} was not found"))
|
36
|
+
end
|
37
|
+
|
38
|
+
cmds = commands_and_aliases
|
39
|
+
if cmds.all? { |cmd| cmd.is_a?(String) }
|
40
|
+
possible_matches = cmds.min_by(2) do |cmd|
|
41
|
+
CLI::Kit::Levenshtein.distance(cmd, name)
|
42
|
+
end
|
43
|
+
|
44
|
+
# We don't want to match against any possible command
|
45
|
+
# so reject anything that is too far away
|
46
|
+
possible_matches.reject! do |possible_match|
|
47
|
+
CLI::Kit::Levenshtein.distance(possible_match, name) > 3
|
48
|
+
end
|
49
|
+
|
50
|
+
# If we have any matches left, tell the user
|
51
|
+
if possible_matches.any?
|
52
|
+
CLI::UI::Frame.open('{{bold:Did you mean?}}', timing: false, color: :blue) do
|
53
|
+
possible_matches.each do |possible_match|
|
54
|
+
$stderr.puts CLI::UI.fmt("{{command:#{@tool_name} #{possible_match}}}")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
sig { returns(T::Array[String]) }
|
62
|
+
def commands_and_aliases
|
63
|
+
@command_registry.command_names + @command_registry.aliases.keys
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# typed: ignore
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module T
|
5
|
+
class << self
|
6
|
+
def absurd(value); end
|
7
|
+
def all(type_a, type_b, *types); end
|
8
|
+
def any(type_a, type_b, *types); end
|
9
|
+
def attached_class; end
|
10
|
+
def class_of(klass); end
|
11
|
+
def enum(values); end
|
12
|
+
def nilable(type); end
|
13
|
+
def noreturn; end
|
14
|
+
def self_type; end
|
15
|
+
def type_alias(type = nil, &_blk); end
|
16
|
+
def type_parameter(name); end
|
17
|
+
def untyped; end
|
18
|
+
|
19
|
+
def assert_type!(value, _type, _checked: true)
|
20
|
+
value
|
21
|
+
end
|
22
|
+
|
23
|
+
def cast(value, _type, _checked: true)
|
24
|
+
value
|
25
|
+
end
|
26
|
+
|
27
|
+
def let(value, _type, _checked: true)
|
28
|
+
value
|
29
|
+
end
|
30
|
+
|
31
|
+
def must(arg, _msg = nil)
|
32
|
+
arg
|
33
|
+
end
|
34
|
+
|
35
|
+
def proc
|
36
|
+
T::Proc.new
|
37
|
+
end
|
38
|
+
|
39
|
+
def reveal_type(value)
|
40
|
+
value
|
41
|
+
end
|
42
|
+
|
43
|
+
def unsafe(value)
|
44
|
+
value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
module Sig
|
49
|
+
def sig(arg0 = nil, &blk); end
|
50
|
+
end
|
51
|
+
|
52
|
+
module Helpers
|
53
|
+
def abstract!; end
|
54
|
+
def interface!; end
|
55
|
+
def final!; end
|
56
|
+
def sealed!; end
|
57
|
+
def mixes_in_class_methods(mod); end
|
58
|
+
end
|
59
|
+
|
60
|
+
module Generic
|
61
|
+
include(T::Helpers)
|
62
|
+
|
63
|
+
def type_parameters(*params); end
|
64
|
+
def type_member(variance = :invariant, fixed: nil, lower: nil, upper: BasicObject); end
|
65
|
+
def type_template(variance = :invariant, fixed: nil, lower: nil, upper: BasicObject); end
|
66
|
+
|
67
|
+
def [](*types)
|
68
|
+
self
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
module Array
|
73
|
+
def self.[](type); end
|
74
|
+
end
|
75
|
+
|
76
|
+
Boolean = Object.new.freeze
|
77
|
+
|
78
|
+
module Configuration
|
79
|
+
def self.call_validation_error_handler(signature, opts); end
|
80
|
+
def self.call_validation_error_handler=(value); end
|
81
|
+
def self.default_checked_level=(default_checked_level); end
|
82
|
+
def self.enable_checking_for_sigs_marked_checked_tests; end
|
83
|
+
def self.enable_final_checks_on_hooks; end
|
84
|
+
def self.enable_legacy_t_enum_migration_mode; end
|
85
|
+
def self.reset_final_checks_on_hooks; end
|
86
|
+
def self.hard_assert_handler(str, extra); end
|
87
|
+
def self.hard_assert_handler=(value); end
|
88
|
+
def self.inline_type_error_handler(error); end
|
89
|
+
def self.inline_type_error_handler=(value); end
|
90
|
+
def self.log_info_handler(str, extra); end
|
91
|
+
def self.log_info_handler=(value); end
|
92
|
+
def self.scalar_types; end
|
93
|
+
def self.scalar_types=(values); end
|
94
|
+
# rubocop:disable Naming/InclusiveLanguage
|
95
|
+
def self.sealed_violation_whitelist; end
|
96
|
+
def self.sealed_violation_whitelist=(sealed_violation_whitelist); end
|
97
|
+
# rubocop:enable Naming/InclusiveLanguage
|
98
|
+
def self.sig_builder_error_handler=(value); end
|
99
|
+
def self.sig_validation_error_handler(error, opts); end
|
100
|
+
def self.sig_validation_error_handler=(value); end
|
101
|
+
def self.soft_assert_handler(str, extra); end
|
102
|
+
def self.soft_assert_handler=(value); end
|
103
|
+
end
|
104
|
+
|
105
|
+
module Enumerable
|
106
|
+
def self.[](type); end
|
107
|
+
end
|
108
|
+
|
109
|
+
module Enumerator
|
110
|
+
def self.[](type); end
|
111
|
+
end
|
112
|
+
|
113
|
+
module Hash
|
114
|
+
def self.[](keys, values); end
|
115
|
+
end
|
116
|
+
|
117
|
+
class Proc
|
118
|
+
def bind(*_)
|
119
|
+
self
|
120
|
+
end
|
121
|
+
|
122
|
+
def params(*_param)
|
123
|
+
self
|
124
|
+
end
|
125
|
+
|
126
|
+
def void
|
127
|
+
self
|
128
|
+
end
|
129
|
+
|
130
|
+
def returns(_type)
|
131
|
+
self
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
module Range
|
136
|
+
def self.[](type); end
|
137
|
+
end
|
138
|
+
|
139
|
+
module Set
|
140
|
+
def self.[](type); end
|
141
|
+
end
|
142
|
+
end
|