cli-kit 5.1.0 → 5.2.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/.rubocop.sorbet.yml +1 -0
- data/.rubocop.yml +1 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +22 -24
- data/Rakefile +0 -1
- data/bin/testunit +0 -1
- data/examples/minimal/example.rb +1 -1
- data/examples/single-file/example.rb +4 -3
- data/gen/lib/gen/commands/help.rb +1 -3
- data/gen/lib/gen/commands/new.rb +2 -6
- data/gen/lib/gen/commands.rb +1 -7
- data/gen/lib/gen/entry_point.rb +1 -5
- data/gen/lib/gen/generator.rb +15 -19
- data/gen/lib/gen/help.rb +3 -7
- data/lib/cli/kit/args/definition.rb +37 -95
- data/lib/cli/kit/args/evaluation.rb +40 -59
- data/lib/cli/kit/args/parser/node.rb +19 -23
- data/lib/cli/kit/args/parser.rb +12 -16
- data/lib/cli/kit/args/tokenizer.rb +15 -18
- data/lib/cli/kit/base_command.rb +4 -8
- data/lib/cli/kit/command_help.rb +24 -27
- data/lib/cli/kit/command_registry.rb +40 -36
- data/lib/cli/kit/config.rb +14 -15
- data/lib/cli/kit/core_ext.rb +4 -6
- data/lib/cli/kit/error_handler.rb +17 -33
- data/lib/cli/kit/executor.rb +7 -16
- data/lib/cli/kit/ini.rb +8 -12
- data/lib/cli/kit/levenshtein.rb +7 -5
- data/lib/cli/kit/logger.rb +8 -10
- data/lib/cli/kit/opts.rb +26 -86
- data/lib/cli/kit/parse_args.rb +5 -10
- data/lib/cli/kit/resolver.rb +4 -6
- data/lib/cli/kit/support/test_helper.rb +10 -5
- data/lib/cli/kit/system.rb +25 -114
- data/lib/cli/kit/util.rb +15 -31
- data/lib/cli/kit/version.rb +1 -1
- data/lib/cli/kit.rb +17 -35
- metadata +1 -2
- data/lib/cli/kit/sorbet_runtime_stub.rb +0 -154
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c397a745de33f27b897f8fd2048874be2f711a56db37ca17f87c5ad169e4f062
|
4
|
+
data.tar.gz: 80332fe8bd9a5dd5fb459f55d2f655a539cc95b13c4a2df174abafaaa4b7c924
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c689fdcf5ae697be38b21ce60e973874c0d6a7f5c0eeaa085b8b93e635a14cbcd3d6af229d0dcb2c7f00084ca58845c3055c687cd6e7fbd4bc8a1902a5582bd2
|
7
|
+
data.tar.gz: 153bf5c66de83e3d332944dfdc6fa9b1d52d4d5413ff80e4cac4b5aafbf0eddc888e22b2e50cf7914b43d1a90f56c23e2f41aaa7ec3987e7c51276092ad6f132
|
data/.rubocop.sorbet.yml
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cli-kit (5.
|
4
|
+
cli-kit (5.2.0)
|
5
5
|
cli-ui (~> 2.4)
|
6
6
|
|
7
7
|
GEM
|
@@ -15,7 +15,7 @@ GEM
|
|
15
15
|
cli-ui (2.4.0)
|
16
16
|
docile (1.4.1)
|
17
17
|
erubi (1.13.1)
|
18
|
-
json (2.
|
18
|
+
json (2.15.1)
|
19
19
|
language_server-protocol (3.17.0.5)
|
20
20
|
lint_roller (1.1.0)
|
21
21
|
logger (1.7.0)
|
@@ -33,18 +33,18 @@ GEM
|
|
33
33
|
parser (3.3.9.0)
|
34
34
|
ast (~> 2.4.1)
|
35
35
|
racc
|
36
|
-
prism (1.
|
36
|
+
prism (1.5.1)
|
37
37
|
racc (1.8.1)
|
38
38
|
rainbow (3.1.1)
|
39
39
|
rake (13.3.0)
|
40
40
|
rbi (0.3.6)
|
41
41
|
prism (~> 1.0)
|
42
42
|
rbs (>= 3.4.4)
|
43
|
-
rbs (3.9.
|
43
|
+
rbs (3.9.5)
|
44
44
|
logger
|
45
|
-
regexp_parser (2.
|
46
|
-
rexml (3.4.
|
47
|
-
rubocop (1.
|
45
|
+
regexp_parser (2.11.3)
|
46
|
+
rexml (3.4.4)
|
47
|
+
rubocop (1.81.1)
|
48
48
|
json (~> 2.3)
|
49
49
|
language_server-protocol (~> 3.17.0.2)
|
50
50
|
lint_roller (~> 1.1.0)
|
@@ -52,11 +52,10 @@ GEM
|
|
52
52
|
parser (>= 3.3.0.2)
|
53
53
|
rainbow (>= 2.2.2, < 4.0)
|
54
54
|
regexp_parser (>= 2.9.3, < 3.0)
|
55
|
-
rubocop-ast (>= 1.
|
55
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
56
56
|
ruby-progressbar (~> 1.7)
|
57
|
-
tsort (>= 0.2.0)
|
58
57
|
unicode-display_width (>= 2.4.0, < 4.0)
|
59
|
-
rubocop-ast (1.
|
58
|
+
rubocop-ast (1.47.1)
|
60
59
|
parser (>= 3.3.7.2)
|
61
60
|
prism (~> 1.4)
|
62
61
|
rubocop-rake (0.7.1)
|
@@ -75,15 +74,15 @@ GEM
|
|
75
74
|
simplecov_json_formatter (~> 0.1)
|
76
75
|
simplecov-html (0.13.2)
|
77
76
|
simplecov_json_formatter (0.1.4)
|
78
|
-
sorbet (0.
|
79
|
-
sorbet-static (= 0.
|
80
|
-
sorbet-runtime (0.
|
81
|
-
sorbet-static (0.
|
82
|
-
sorbet-static (0.
|
83
|
-
sorbet-static (0.
|
84
|
-
sorbet-static-and-runtime (0.
|
85
|
-
sorbet (= 0.
|
86
|
-
sorbet-runtime (= 0.
|
77
|
+
sorbet (0.6.12627)
|
78
|
+
sorbet-static (= 0.6.12627)
|
79
|
+
sorbet-runtime (0.6.12627)
|
80
|
+
sorbet-static (0.6.12627-aarch64-linux)
|
81
|
+
sorbet-static (0.6.12627-universal-darwin)
|
82
|
+
sorbet-static (0.6.12627-x86_64-linux)
|
83
|
+
sorbet-static-and-runtime (0.6.12627)
|
84
|
+
sorbet (= 0.6.12627)
|
85
|
+
sorbet-runtime (= 0.6.12627)
|
87
86
|
spoom (1.6.3)
|
88
87
|
erubi (>= 1.10.0)
|
89
88
|
prism (>= 0.28.0)
|
@@ -102,10 +101,9 @@ GEM
|
|
102
101
|
thor (>= 1.2.0)
|
103
102
|
yard-sorbet
|
104
103
|
thor (1.4.0)
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
unicode-emoji (4.0.4)
|
104
|
+
unicode-display_width (3.2.0)
|
105
|
+
unicode-emoji (~> 4.1)
|
106
|
+
unicode-emoji (4.1.0)
|
109
107
|
yard (0.9.37)
|
110
108
|
yard-sorbet (0.9.0)
|
111
109
|
sorbet-runtime
|
@@ -131,7 +129,7 @@ DEPENDENCIES
|
|
131
129
|
rubocop-shopify
|
132
130
|
rubocop-sorbet
|
133
131
|
simplecov
|
134
|
-
sorbet-static
|
132
|
+
sorbet-static
|
135
133
|
tapioca
|
136
134
|
|
137
135
|
BUNDLED WITH
|
data/Rakefile
CHANGED
data/bin/testunit
CHANGED
data/examples/minimal/example.rb
CHANGED
@@ -11,7 +11,7 @@ include(CLI::Kit)
|
|
11
11
|
registry = CommandRegistry.new(default: 'hello')
|
12
12
|
registry.add(
|
13
13
|
Class.new(BaseCommand) do
|
14
|
-
|
14
|
+
#: (Array[String], String) -> void
|
15
15
|
def call(_args, _name)
|
16
16
|
puts 'hello, world!'
|
17
17
|
end
|
@@ -15,7 +15,7 @@ module Example
|
|
15
15
|
Registry = CLI::Kit::CommandRegistry.new(default: 'hello')
|
16
16
|
|
17
17
|
class << self
|
18
|
-
|
18
|
+
#: (Symbol const, String cmd, String path, ^-> Example::Command lamda_const) -> void
|
19
19
|
def register(const, cmd, path, lamda_const)
|
20
20
|
autoload(const, path)
|
21
21
|
Registry.add(lamda_const, cmd)
|
@@ -25,7 +25,8 @@ module Example
|
|
25
25
|
end
|
26
26
|
|
27
27
|
class Hello < Example::Command
|
28
|
-
|
28
|
+
# @override
|
29
|
+
#: (Array[String] _args, String _name) -> void
|
29
30
|
def call(_args, _name)
|
30
31
|
puts 'hello, world!'
|
31
32
|
end
|
@@ -34,7 +35,7 @@ module Example
|
|
34
35
|
|
35
36
|
module EntryPoint
|
36
37
|
class << self
|
37
|
-
|
38
|
+
#: (Array[String] args) -> void
|
38
39
|
def call(args)
|
39
40
|
cmd, command_name, args = Example::Resolver.call(args)
|
40
41
|
Example::Executor.call(cmd, command_name, args)
|
@@ -5,11 +5,9 @@ require 'gen'
|
|
5
5
|
module Gen
|
6
6
|
module Commands
|
7
7
|
class Help < Gen::Command
|
8
|
-
extend T::Sig
|
9
|
-
|
10
8
|
desc('Show help for a command, or this page')
|
11
9
|
|
12
|
-
|
10
|
+
#: (Array[String] args, String _name) -> void
|
13
11
|
def call(args, _name)
|
14
12
|
Gen::Help.generate(args)
|
15
13
|
end
|
data/gen/lib/gen/commands/new.rb
CHANGED
@@ -5,8 +5,6 @@ require 'gen'
|
|
5
5
|
module Gen
|
6
6
|
module Commands
|
7
7
|
class New < Gen::Command
|
8
|
-
extend T::Sig
|
9
|
-
|
10
8
|
command_name('new')
|
11
9
|
desc('Create a new project')
|
12
10
|
long_desc(<<~LONGDESC)
|
@@ -18,15 +16,13 @@ module Gen
|
|
18
16
|
example('mycliapp', "create a new project called 'mycliapp'")
|
19
17
|
|
20
18
|
class Opts < CLI::Kit::Opts
|
21
|
-
|
22
|
-
|
23
|
-
sig { returns(String) }
|
19
|
+
#: -> String
|
24
20
|
def project_name
|
25
21
|
position!
|
26
22
|
end
|
27
23
|
end
|
28
24
|
|
29
|
-
|
25
|
+
#: (Opts op, untyped _name) -> untyped
|
30
26
|
def invoke(op, _name)
|
31
27
|
Gen::Generator.run(op.project_name)
|
32
28
|
end
|
data/gen/lib/gen/commands.rb
CHANGED
@@ -4,16 +4,10 @@ require 'gen'
|
|
4
4
|
|
5
5
|
module Gen
|
6
6
|
module Commands
|
7
|
-
extend T::Sig
|
8
|
-
|
9
7
|
Registry = CLI::Kit::CommandRegistry.new(default: 'help')
|
10
8
|
|
11
9
|
class << self
|
12
|
-
|
13
|
-
|
14
|
-
sig do
|
15
|
-
params(const: Symbol, cmd: String, path: String, lamda_const: T.proc.returns(T.class_of(Gen::Command))).void
|
16
|
-
end
|
10
|
+
#: (Symbol const, String cmd, String path, ^-> singleton(Gen::Command) lamda_const) -> void
|
17
11
|
def register(const, cmd, path, lamda_const)
|
18
12
|
autoload(const, path)
|
19
13
|
Registry.add(lamda_const, cmd)
|
data/gen/lib/gen/entry_point.rb
CHANGED
@@ -4,12 +4,8 @@ require 'gen'
|
|
4
4
|
|
5
5
|
module Gen
|
6
6
|
module EntryPoint
|
7
|
-
extend T::Sig
|
8
|
-
|
9
7
|
class << self
|
10
|
-
|
11
|
-
|
12
|
-
sig { params(args: T::Array[String]).void }
|
8
|
+
#: (Array[String] args) -> void
|
13
9
|
def call(args)
|
14
10
|
cmd, command_name, args = Gen::Resolver.call(args)
|
15
11
|
Gen::Executor.call(cmd, command_name, args)
|
data/gen/lib/gen/generator.rb
CHANGED
@@ -8,12 +8,8 @@ require 'tmpdir'
|
|
8
8
|
|
9
9
|
module Gen
|
10
10
|
class Generator
|
11
|
-
extend T::Sig
|
12
|
-
|
13
11
|
class << self
|
14
|
-
|
15
|
-
|
16
|
-
sig { params(project_name: String).void }
|
12
|
+
#: (String project_name) -> void
|
17
13
|
def run(project_name)
|
18
14
|
new(project_name).run
|
19
15
|
end
|
@@ -44,7 +40,7 @@ module Gen
|
|
44
40
|
}.freeze
|
45
41
|
private_constant :BUNDLER_TRANSLATIONS
|
46
42
|
|
47
|
-
|
43
|
+
#: (String project_name) -> void
|
48
44
|
def initialize(project_name)
|
49
45
|
raise(
|
50
46
|
CLI::Kit::Abort,
|
@@ -54,7 +50,7 @@ module Gen
|
|
54
50
|
@title_case_project_name = @project_name.sub(/^./, &:upcase)
|
55
51
|
end
|
56
52
|
|
57
|
-
|
53
|
+
#: -> void
|
58
54
|
def run
|
59
55
|
vendor = ask_vendor?
|
60
56
|
create_project_dir
|
@@ -68,12 +64,12 @@ module Gen
|
|
68
64
|
|
69
65
|
private
|
70
66
|
|
71
|
-
|
67
|
+
#: -> bool
|
72
68
|
def ask_vendor?
|
73
69
|
return true if ENV['DEPS'] == 'vendor'
|
74
70
|
return false if ENV['DEPS'] == 'bundler'
|
75
71
|
|
76
|
-
vendor =
|
72
|
+
vendor = nil #: String?
|
77
73
|
CLI::UI::Frame.open('Configuration') do
|
78
74
|
q = 'How would you like the application to consume {{command:cli-kit}} and {{command:cli-ui}}?'
|
79
75
|
vendor = CLI::UI::Prompt.ask(q) do |c|
|
@@ -84,7 +80,7 @@ module Gen
|
|
84
80
|
vendor == 'vendor'
|
85
81
|
end
|
86
82
|
|
87
|
-
|
83
|
+
#: -> void
|
88
84
|
def create_project_dir
|
89
85
|
info(create: '')
|
90
86
|
FileUtils.mkdir(@project_name)
|
@@ -92,7 +88,7 @@ module Gen
|
|
92
88
|
error("directory already exists: #{@project_name}")
|
93
89
|
end
|
94
90
|
|
95
|
-
|
91
|
+
#: (translations: Hash[String, (FalseClass | String)]) -> void
|
96
92
|
def copy_files(translations:)
|
97
93
|
each_template_file do |source_name|
|
98
94
|
target_name = translations.fetch(source_name, source_name)
|
@@ -115,7 +111,7 @@ module Gen
|
|
115
111
|
end
|
116
112
|
end
|
117
113
|
|
118
|
-
|
114
|
+
#: -> void
|
119
115
|
def update_deps
|
120
116
|
Dir.mktmpdir do |tmp|
|
121
117
|
clone(tmp, 'cli-ui')
|
@@ -127,7 +123,7 @@ module Gen
|
|
127
123
|
end
|
128
124
|
end
|
129
125
|
|
130
|
-
|
126
|
+
#: (String dir, String repo) -> void
|
131
127
|
def clone(dir, repo)
|
132
128
|
info(clone: repo)
|
133
129
|
out, stat = Open3.capture2e('git', '-C', dir, 'clone', "https://github.com/shopify/#{repo}")
|
@@ -137,7 +133,7 @@ module Gen
|
|
137
133
|
end
|
138
134
|
end
|
139
135
|
|
140
|
-
|
136
|
+
#: { (String rel_path) -> void } -> void
|
141
137
|
def each_template_file(&block)
|
142
138
|
root = Pathname.new(TEMPLATE_ROOT)
|
143
139
|
Dir.glob("#{TEMPLATE_ROOT}/**/*").each do |f|
|
@@ -146,7 +142,7 @@ module Gen
|
|
146
142
|
end
|
147
143
|
end
|
148
144
|
|
149
|
-
|
145
|
+
#: (String s) -> String
|
150
146
|
def apply_template_variables(s)
|
151
147
|
s
|
152
148
|
.gsub('__app__', @project_name)
|
@@ -155,19 +151,19 @@ module Gen
|
|
155
151
|
.gsub('__cli-ui-version__', cli_ui_version)
|
156
152
|
end
|
157
153
|
|
158
|
-
|
154
|
+
#: -> String
|
159
155
|
def cli_kit_version
|
160
156
|
require 'cli/kit/version'
|
161
157
|
CLI::Kit::VERSION.to_s
|
162
158
|
end
|
163
159
|
|
164
|
-
|
160
|
+
#: -> String
|
165
161
|
def cli_ui_version
|
166
162
|
require 'cli/ui/version'
|
167
163
|
CLI::UI::VERSION.to_s
|
168
164
|
end
|
169
165
|
|
170
|
-
|
166
|
+
#: (?create: String?, ?clone: String?, ?run: String?) -> void
|
171
167
|
def info(create: nil, clone: nil, run: nil)
|
172
168
|
if clone
|
173
169
|
puts(CLI::UI.fmt("\t{{bold:{{yellow:clone}}\t#{clone}}}"))
|
@@ -178,7 +174,7 @@ module Gen
|
|
178
174
|
end
|
179
175
|
end
|
180
176
|
|
181
|
-
|
177
|
+
#: (String msg) -> void
|
182
178
|
def error(msg)
|
183
179
|
raise(CLI::Kit::Abort, msg)
|
184
180
|
end
|
data/gen/lib/gen/help.rb
CHANGED
@@ -4,12 +4,8 @@ require 'gen'
|
|
4
4
|
|
5
5
|
module Gen
|
6
6
|
module Help
|
7
|
-
extend T::Sig
|
8
|
-
|
9
7
|
class << self
|
10
|
-
|
11
|
-
|
12
|
-
sig { params(path: T::Array[String], to: IO).void }
|
8
|
+
#: (Array[String] path, ?to: IO) -> void
|
13
9
|
def generate(path, to: STDOUT)
|
14
10
|
case path.size
|
15
11
|
when 0
|
@@ -21,7 +17,7 @@ module Gen
|
|
21
17
|
end
|
22
18
|
end
|
23
19
|
|
24
|
-
|
20
|
+
#: (?to: IO) -> void
|
25
21
|
def generate_toplevel(to: STDOUT)
|
26
22
|
to.write(CLI::UI.fmt(<<~HELP))
|
27
23
|
{{bold:{{command:cli-kit}} generates new cli-kit apps.}}
|
@@ -44,7 +40,7 @@ module Gen
|
|
44
40
|
end
|
45
41
|
end
|
46
42
|
|
47
|
-
|
43
|
+
#: (String cmd_name, ?to: IO) -> void
|
48
44
|
def generate_command_help(cmd_name, to: STDOUT)
|
49
45
|
klass = Gen::Commands::Registry.resolved_commands[cmd_name]
|
50
46
|
unless klass
|