cli-kit 4.0.0 → 5.0.1
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/.github/dependabot.yml +3 -0
- data/.github/workflows/cla.yml +22 -0
- data/.github/workflows/ruby.yml +16 -2
- data/.gitignore +2 -0
- data/.rubocop.sorbet.yml +47 -0
- data/.rubocop.yml +32 -1
- data/.ruby-version +1 -0
- data/Gemfile +10 -1
- data/Gemfile.lock +102 -29
- data/README.md +46 -3
- data/Rakefile +1 -0
- data/bin/onchange +30 -0
- data/bin/tapioca +28 -0
- data/bin/testunit +1 -0
- data/cli-kit.gemspec +9 -4
- data/dev.yml +38 -3
- data/examples/minimal/example.rb +11 -6
- data/examples/single-file/example.rb +25 -35
- data/gen/lib/gen/commands/help.rb +8 -10
- data/gen/lib/gen/commands/new.rb +23 -9
- data/gen/lib/gen/commands.rb +21 -9
- data/gen/lib/gen/entry_point.rb +12 -3
- data/gen/lib/gen/generator.rb +32 -11
- data/gen/lib/gen/help.rb +63 -0
- data/gen/lib/gen.rb +18 -23
- data/gen/template/bin/update-deps +2 -2
- data/gen/template/dev-gems.yml +1 -1
- data/gen/template/dev-vendor.yml +1 -1
- data/gen/template/lib/__app__/commands.rb +1 -4
- data/gen/template/lib/__app__.rb +8 -17
- data/gen/template/test/example_test.rb +1 -1
- data/lib/cli/kit/args/definition.rb +344 -0
- data/lib/cli/kit/args/evaluation.rb +234 -0
- data/lib/cli/kit/args/parser/node.rb +132 -0
- data/lib/cli/kit/args/parser.rb +129 -0
- data/lib/cli/kit/args/tokenizer.rb +133 -0
- data/lib/cli/kit/args.rb +16 -0
- data/lib/cli/kit/base_command.rb +17 -32
- data/lib/cli/kit/command_help.rb +271 -0
- data/lib/cli/kit/command_registry.rb +72 -20
- data/lib/cli/kit/config.rb +25 -22
- data/lib/cli/kit/core_ext.rb +30 -0
- data/lib/cli/kit/error_handler.rb +131 -70
- data/lib/cli/kit/executor.rb +20 -3
- data/lib/cli/kit/ini.rb +31 -38
- data/lib/cli/kit/levenshtein.rb +12 -4
- data/lib/cli/kit/logger.rb +16 -2
- data/lib/cli/kit/opts.rb +301 -0
- data/lib/cli/kit/parse_args.rb +55 -0
- data/lib/cli/kit/resolver.rb +8 -0
- data/lib/cli/kit/sorbet_runtime_stub.rb +154 -0
- data/lib/cli/kit/support/test_helper.rb +27 -16
- data/lib/cli/kit/support.rb +2 -0
- data/lib/cli/kit/system.rb +194 -57
- data/lib/cli/kit/util.rb +48 -103
- data/lib/cli/kit/version.rb +3 -1
- data/lib/cli/kit.rb +104 -7
- metadata +30 -14
- data/.github/probots.yml +0 -2
- data/lib/cli/kit/autocall.rb +0 -21
- data/lib/cli/kit/ruby_backports/enumerable.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af93e4820420cf1704d8cca5d63107f7bd83961100daa6db8e7f8548680cd10e
|
4
|
+
data.tar.gz: 4894fe464e5be800e850a9543978bb80f3353837ed8e52b63a8cd60f1167f951
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d47834888929cf73123f2ecb5ca47676f530fbc51355f54b1dd4ef098f6f1afa5f0603d4e6c468326d114324ff467487085dced9cd24bf67ac87890ec4eadb8
|
7
|
+
data.tar.gz: f49180d83cf371a0e5f8870c95a5dcfdb44add7ab4938ba6cb24adb1de034a2526c9505b5eba1cd731d28e8b2089fbce748dec6c5191dcdc140a44713f6f6c79
|
data/.github/dependabot.yml
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
name: Contributor License Agreement (CLA)
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request_target:
|
5
|
+
types: [opened, synchronize]
|
6
|
+
issue_comment:
|
7
|
+
types: [created]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
cla:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
if: |
|
13
|
+
(github.event.issue.pull_request
|
14
|
+
&& !github.event.issue.pull_request.merged_at
|
15
|
+
&& contains(github.event.comment.body, 'signed')
|
16
|
+
)
|
17
|
+
|| (github.event.pull_request && !github.event.pull_request.merged)
|
18
|
+
steps:
|
19
|
+
- uses: Shopify/shopify-cla-action@v1
|
20
|
+
with:
|
21
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
22
|
+
cla-token: ${{ secrets.CLA_TOKEN }}
|
data/.github/workflows/ruby.yml
CHANGED
@@ -3,6 +3,7 @@ name: Ruby
|
|
3
3
|
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
|
+
|
6
7
|
style:
|
7
8
|
runs-on: ubuntu-latest
|
8
9
|
steps:
|
@@ -10,17 +11,30 @@ jobs:
|
|
10
11
|
- name: Set up Ruby
|
11
12
|
uses: ruby/setup-ruby@v1
|
12
13
|
with:
|
13
|
-
ruby-version: '2.7'
|
14
14
|
bundler-cache: true
|
15
15
|
- name: Check style
|
16
16
|
run: bundle exec rake style
|
17
|
+
|
18
|
+
typecheck:
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v2
|
22
|
+
- name: Set up Ruby
|
23
|
+
uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
bundler-cache: true
|
26
|
+
- name: Typecheck
|
27
|
+
run: bundle exec srb tc
|
28
|
+
|
17
29
|
test:
|
18
30
|
strategy:
|
19
31
|
matrix:
|
20
32
|
os: [macos-latest, ubuntu-latest, windows-latest]
|
21
|
-
ruby-version: ['
|
33
|
+
ruby-version: ['3.1', '3.2', '3.3']
|
22
34
|
|
23
35
|
runs-on: ${{ matrix.os }}
|
36
|
+
env:
|
37
|
+
BUNDLE_WITHOUT: typecheck
|
24
38
|
steps:
|
25
39
|
- uses: actions/checkout@v2
|
26
40
|
- name: Set up Ruby
|
data/.gitignore
CHANGED
data/.rubocop.sorbet.yml
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
Sorbet:
|
2
|
+
Enabled: true
|
3
|
+
|
4
|
+
Sorbet/ValidSigil:
|
5
|
+
Enabled: true
|
6
|
+
Exclude:
|
7
|
+
- lib/cli/kit/sorbet_runtime_stub.rb
|
8
|
+
|
9
|
+
Sorbet/FalseSigil:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Sorbet/TrueSigil:
|
13
|
+
Enabled: true
|
14
|
+
Include:
|
15
|
+
- "**/*.rb"
|
16
|
+
- "**/*.rbi"
|
17
|
+
- "**/*.rake"
|
18
|
+
- "**/*.ru"
|
19
|
+
Exclude:
|
20
|
+
- lib/cli/kit/sorbet_runtime_stub.rb
|
21
|
+
- "test/**/*"
|
22
|
+
- "lib/cli/kit/support/test_helper.rb"
|
23
|
+
|
24
|
+
Sorbet/EnforceSigilOrder:
|
25
|
+
Enabled: true
|
26
|
+
|
27
|
+
Sorbet/EnforceSignatures:
|
28
|
+
Enabled: true
|
29
|
+
Exclude:
|
30
|
+
- lib/cli/kit/sorbet_runtime_stub.rb
|
31
|
+
- "test/**/*"
|
32
|
+
- bin/testunit
|
33
|
+
- "lib/cli/kit/support/test_helper.rb"
|
34
|
+
|
35
|
+
Sorbet/SignatureBuildOrder:
|
36
|
+
Enabled: true
|
37
|
+
|
38
|
+
Sorbet/KeywordArgumentOrdering:
|
39
|
+
Enabled: true
|
40
|
+
|
41
|
+
Sorbet/ConstantsFromStrings:
|
42
|
+
Enabled: true
|
43
|
+
Exclude:
|
44
|
+
- "examples/**/*"
|
45
|
+
|
46
|
+
Sorbet/ForbidIncludeConstLiteral:
|
47
|
+
Enabled: false
|
data/.rubocop.yml
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
inherit_gem:
|
2
2
|
rubocop-shopify: rubocop-cli.yml
|
3
3
|
|
4
|
+
inherit_from:
|
5
|
+
- .rubocop.sorbet.yml
|
6
|
+
|
7
|
+
require:
|
8
|
+
- rubocop-sorbet
|
9
|
+
|
4
10
|
AllCops:
|
5
11
|
Exclude:
|
6
12
|
- gen/template/**/*
|
7
13
|
- vendor/**/*
|
8
|
-
|
14
|
+
- lib/cli/kit/levenshtein.rb # Vendored
|
15
|
+
NewCops: disable
|
9
16
|
|
10
17
|
Style/ClassAndModuleChildren:
|
11
18
|
Exclude:
|
@@ -36,3 +43,27 @@ Style/MultilineBlockChain:
|
|
36
43
|
|
37
44
|
Style/StringLiterals:
|
38
45
|
EnforcedStyle: single_quotes
|
46
|
+
|
47
|
+
# We heavily manage output on purpose
|
48
|
+
Style/GlobalStdStream:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
# Sometimes (often) explicit is good
|
52
|
+
Style/EmptyElse:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
# We make frequent use Open3 methods to run other programs. When passing long command lines, it's useful and informative
|
56
|
+
# to place the argument to an option on the same line as its option, eg:
|
57
|
+
# Open3.capture3(
|
58
|
+
# 'curl',
|
59
|
+
# '-H', 'X-Header: value',
|
60
|
+
# '-o', 'file.txt',
|
61
|
+
# '-L',
|
62
|
+
# 'https://example.com/',
|
63
|
+
# )
|
64
|
+
Layout/MultilineMethodArgumentLineBreaks:
|
65
|
+
Enabled: false
|
66
|
+
Layout/MultilineArrayLineBreaks:
|
67
|
+
Enabled: false
|
68
|
+
Layout/MultilineHashKeyLineBreaks:
|
69
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.3.0
|
data/Gemfile
CHANGED
@@ -4,14 +4,23 @@ source 'https://rubygems.org'
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
group :development, :test do
|
7
|
+
gem 'cli-ui'
|
7
8
|
gem 'rubocop'
|
9
|
+
gem 'rubocop-rake'
|
8
10
|
gem 'rubocop-shopify'
|
11
|
+
gem 'rubocop-sorbet'
|
9
12
|
gem 'byebug'
|
10
13
|
gem 'method_source'
|
14
|
+
gem 'simplecov'
|
15
|
+
end
|
16
|
+
|
17
|
+
group :typecheck do
|
18
|
+
gem 'sorbet-static-and-runtime'
|
19
|
+
gem 'tapioca', require: false
|
11
20
|
end
|
12
21
|
|
13
22
|
group :test do
|
14
|
-
gem 'mocha', '~>
|
23
|
+
gem 'mocha', '~> 2.4.0', require: false
|
15
24
|
gem 'minitest', '>= 5.0.0', require: false
|
16
25
|
gem 'minitest-reporters', require: false
|
17
26
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,62 +1,135 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cli-kit (
|
5
|
-
cli-ui (
|
4
|
+
cli-kit (5.0.1)
|
5
|
+
cli-ui (~> 2.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
ansi (1.5.0)
|
11
11
|
ast (2.4.2)
|
12
|
-
|
12
|
+
benchmark (0.4.0)
|
13
|
+
builder (3.3.0)
|
13
14
|
byebug (11.1.3)
|
14
|
-
cli-ui (
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
cli-ui (2.3.0)
|
16
|
+
docile (1.4.1)
|
17
|
+
erubi (1.13.1)
|
18
|
+
json (2.10.1)
|
19
|
+
language_server-protocol (3.17.0.4)
|
20
|
+
lint_roller (1.1.0)
|
21
|
+
logger (1.6.6)
|
22
|
+
method_source (1.1.0)
|
23
|
+
minitest (5.25.4)
|
24
|
+
minitest-reporters (1.7.1)
|
18
25
|
ansi
|
19
26
|
builder
|
20
27
|
minitest (>= 5.0)
|
21
28
|
ruby-progressbar
|
22
|
-
mocha (
|
23
|
-
|
24
|
-
|
29
|
+
mocha (2.4.5)
|
30
|
+
ruby2_keywords (>= 0.0.5)
|
31
|
+
netrc (0.11.0)
|
32
|
+
parallel (1.26.3)
|
33
|
+
parser (3.3.7.1)
|
25
34
|
ast (~> 2.4.1)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
35
|
+
racc
|
36
|
+
prism (1.3.0)
|
37
|
+
racc (1.8.1)
|
38
|
+
rainbow (3.1.1)
|
39
|
+
rake (13.2.1)
|
40
|
+
rbi (0.3.0)
|
41
|
+
prism (~> 1.0)
|
42
|
+
rbs (>= 3.4.4)
|
43
|
+
sorbet-runtime (>= 0.5.9204)
|
44
|
+
rbs (3.8.1)
|
45
|
+
logger
|
46
|
+
regexp_parser (2.10.0)
|
47
|
+
rubocop (1.73.2)
|
48
|
+
json (~> 2.3)
|
49
|
+
language_server-protocol (~> 3.17.0.2)
|
50
|
+
lint_roller (~> 1.1.0)
|
31
51
|
parallel (~> 1.10)
|
32
|
-
parser (>= 3.
|
52
|
+
parser (>= 3.3.0.2)
|
33
53
|
rainbow (>= 2.2.2, < 4.0)
|
34
|
-
regexp_parser (>=
|
35
|
-
|
36
|
-
rubocop-ast (>= 1.12.0, < 2.0)
|
54
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
55
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
37
56
|
ruby-progressbar (~> 1.7)
|
38
|
-
unicode-display_width (>=
|
39
|
-
rubocop-ast (1.
|
40
|
-
parser (>= 3.
|
41
|
-
rubocop-
|
42
|
-
|
43
|
-
|
44
|
-
|
57
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
58
|
+
rubocop-ast (1.38.1)
|
59
|
+
parser (>= 3.3.1.0)
|
60
|
+
rubocop-rake (0.7.1)
|
61
|
+
lint_roller (~> 1.1)
|
62
|
+
rubocop (>= 1.72.1)
|
63
|
+
rubocop-shopify (2.16.0)
|
64
|
+
rubocop (~> 1.62)
|
65
|
+
rubocop-sorbet (0.9.0)
|
66
|
+
lint_roller (~> 1.1)
|
67
|
+
rubocop (>= 1)
|
68
|
+
ruby-progressbar (1.13.0)
|
69
|
+
ruby2_keywords (0.0.5)
|
70
|
+
simplecov (0.22.0)
|
71
|
+
docile (~> 1.1)
|
72
|
+
simplecov-html (~> 0.11)
|
73
|
+
simplecov_json_formatter (~> 0.1)
|
74
|
+
simplecov-html (0.13.1)
|
75
|
+
simplecov_json_formatter (0.1.4)
|
76
|
+
sorbet (0.5.11915)
|
77
|
+
sorbet-static (= 0.5.11915)
|
78
|
+
sorbet-runtime (0.5.11915)
|
79
|
+
sorbet-static (0.5.11915-universal-darwin)
|
80
|
+
sorbet-static (0.5.11915-x86_64-linux)
|
81
|
+
sorbet-static-and-runtime (0.5.11915)
|
82
|
+
sorbet (= 0.5.11915)
|
83
|
+
sorbet-runtime (= 0.5.11915)
|
84
|
+
spoom (1.5.4)
|
85
|
+
erubi (>= 1.10.0)
|
86
|
+
prism (>= 0.28.0)
|
87
|
+
rbi (>= 0.2.3)
|
88
|
+
sorbet-static-and-runtime (>= 0.5.10187)
|
89
|
+
thor (>= 0.19.2)
|
90
|
+
tapioca (0.16.11)
|
91
|
+
benchmark
|
92
|
+
bundler (>= 2.2.25)
|
93
|
+
netrc (>= 0.11.0)
|
94
|
+
parallel (>= 1.21.0)
|
95
|
+
rbi (~> 0.2)
|
96
|
+
sorbet-static-and-runtime (>= 0.5.11087)
|
97
|
+
spoom (>= 1.2.0)
|
98
|
+
thor (>= 1.2.0)
|
99
|
+
yard-sorbet
|
100
|
+
thor (1.3.2)
|
101
|
+
unicode-display_width (3.1.4)
|
102
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
103
|
+
unicode-emoji (4.0.4)
|
104
|
+
yard (0.9.37)
|
105
|
+
yard-sorbet (0.9.0)
|
106
|
+
sorbet-runtime
|
107
|
+
yard
|
45
108
|
|
46
109
|
PLATFORMS
|
47
|
-
|
110
|
+
arm64-darwin-21
|
111
|
+
universal-darwin
|
112
|
+
x64-mingw-ucrt
|
113
|
+
x64-mingw32
|
114
|
+
x86_64-linux
|
48
115
|
|
49
116
|
DEPENDENCIES
|
50
117
|
bundler (~> 2.1)
|
51
118
|
byebug
|
52
119
|
cli-kit!
|
120
|
+
cli-ui
|
53
121
|
method_source
|
54
122
|
minitest (>= 5.0.0)
|
55
123
|
minitest-reporters
|
56
|
-
mocha (~>
|
124
|
+
mocha (~> 2.4.0)
|
57
125
|
rake (~> 13.0)
|
58
126
|
rubocop
|
127
|
+
rubocop-rake
|
59
128
|
rubocop-shopify
|
129
|
+
rubocop-sorbet
|
130
|
+
simplecov
|
131
|
+
sorbet-static-and-runtime
|
132
|
+
tapioca
|
60
133
|
|
61
134
|
BUNDLED WITH
|
62
|
-
2.
|
135
|
+
2.4.9
|
data/README.md
CHANGED
@@ -26,9 +26,52 @@ select how the project consumes `cli-kit` and `cli-ui`. The available options a
|
|
26
26
|
|
27
27
|
You're now ready to write your very first `cli-kit` application!
|
28
28
|
|
29
|
+
## Upgrading to version 5
|
30
|
+
|
31
|
+
Version 5 includes breaking changes and significant new features. Notably:
|
32
|
+
|
33
|
+
* `autocall` is completely removed;
|
34
|
+
* A help system and command-line option parsing system is added.
|
35
|
+
|
36
|
+
Migrating away from `autocall` is as simple as replacing `autocall(:X) { y }` with `X = y`.
|
37
|
+
|
38
|
+
Using the new help system is not yet well-documented, but some hints can be found in the
|
39
|
+
`gen/ilb/gen/commands` directory of this repo. Existing commands in existing apps should continue to
|
40
|
+
work.
|
41
|
+
|
42
|
+
To use the new help system, commands should all define `invoke` instead of `call`. `invoke` takes
|
43
|
+
`name` as before, but the first argument is now an instance of `Opts`, defined in the command class,
|
44
|
+
which must be a subclass of `CLI::Kit::Opts`. For example:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
class MyCommand < CLI::Kit::BaseCommand
|
48
|
+
class Opts < CLI::Kit::Opts
|
49
|
+
def force
|
50
|
+
flag(short: '-f', long: '--force', description: 'Force the operation')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
def invoke(op, _name)
|
54
|
+
if op.force
|
55
|
+
puts 'Forcing the operation'
|
56
|
+
else
|
57
|
+
puts 'Not forcing the operation'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
This particular structure was chosen to allow the code to by fully typed using sorbet, as `invoke`
|
64
|
+
can be tagged with `sig { params(op: Opts, _name: String).void }`, and the `#force` method visibly
|
65
|
+
exists.
|
66
|
+
|
67
|
+
`-h/--help` is installed as a default flag, and running this command with `--help` is handled before
|
68
|
+
reaching `#invoke`, to print a help message (for which several other class methods on `BaseCommand`
|
69
|
+
provide text: `command_name`, `desc`, `long_desc`, `usage`, `example`, and `help_sections`). See
|
70
|
+
`gen/lib/gen/commands/new.rb` for an example.
|
71
|
+
|
29
72
|
## How do `cli-kit` Applications Work?
|
30
73
|
|
31
|
-
The executable for your `cli-kit` app is stored in the "exe" directory.
|
74
|
+
The executable for your `cli-kit` app is stored in the "exe" directory. To execute the app, simply
|
32
75
|
run:
|
33
76
|
```bash
|
34
77
|
./exe/myproject
|
@@ -38,7 +81,7 @@ run:
|
|
38
81
|
* `/exe/` - Location of the executables for your application.
|
39
82
|
* `/lib/` - Location of the resources for your app (modules, classes, helpers, etc).
|
40
83
|
* `myproject.rb` - This file is the starting point for where to look for all other files. It
|
41
|
-
configures autoload
|
84
|
+
configures autoload for the app.
|
42
85
|
* `myproject/` - Stores the various commands/entry points.
|
43
86
|
* `entry_point.rb` - This is the file that is first called from the executable. It handles
|
44
87
|
loading and commands.
|
@@ -113,4 +156,4 @@ powerful command-line user interface elements. For more details on how to use `c
|
|
113
156
|
|
114
157
|
## Examples
|
115
158
|
|
116
|
-
- [A Simple To-Do App](https://github.com/Shopify/cli-kit-example)
|
159
|
+
- [A Simple To-Do App](https://github.com/Shopify/cli-kit-example)
|
data/Rakefile
CHANGED
data/bin/onchange
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# typed: ignore
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require('open3')
|
6
|
+
|
7
|
+
extra_fswatch_args, cmd_args = if (rest_index = ARGV.index('--'))
|
8
|
+
[ARGV[0...rest_index], ARGV[rest_index + 1..-1]]
|
9
|
+
else
|
10
|
+
[[], ARGV]
|
11
|
+
end
|
12
|
+
|
13
|
+
if cmd_args.size == 1 && cmd_args =~ /[&;|]/
|
14
|
+
cmd_args = ['bash', '-c', cmd_args[0]]
|
15
|
+
end
|
16
|
+
|
17
|
+
system(*cmd_args)
|
18
|
+
|
19
|
+
fswatch_args = [
|
20
|
+
'-e', 'coverage',
|
21
|
+
'-e', '/\.git',
|
22
|
+
'--one-per-batch',
|
23
|
+
*extra_fswatch_args,
|
24
|
+
'.',
|
25
|
+
]
|
26
|
+
|
27
|
+
Open3.popen3('fswatch', *fswatch_args) do |stdin, stdout, _stderr, _wait_thr|
|
28
|
+
stdin.close
|
29
|
+
stdout.each { |_| system(*cmd_args) }
|
30
|
+
end
|
data/bin/tapioca
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'tapioca' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'pathname'
|
12
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
|
13
|
+
|
14
|
+
bundle_binstub = File.expand_path('../bundle', __FILE__)
|
15
|
+
|
16
|
+
if File.file?(bundle_binstub)
|
17
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
18
|
+
load(bundle_binstub)
|
19
|
+
else
|
20
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
21
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'rubygems'
|
26
|
+
require 'bundler/setup'
|
27
|
+
|
28
|
+
load Gem.bin_path('tapioca', 'tapioca')
|
data/bin/testunit
CHANGED
data/cli-kit.gemspec
CHANGED
@@ -7,8 +7,11 @@ require 'cli/kit/version'
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = 'cli-kit'
|
9
9
|
spec.version = CLI::Kit::VERSION
|
10
|
-
spec.authors = ['Burke Libbey', 'Aaron Olson', 'Lisa Ugray']
|
11
|
-
spec.email = [
|
10
|
+
spec.authors = ['Burke Libbey', 'Aaron Olson', 'Lisa Ugray', 'Don Kelly']
|
11
|
+
spec.email = [
|
12
|
+
'burke.libbey@shopify.com', 'aaron.olson@shopify.com', 'lisa.ugray@shopify.com',
|
13
|
+
'don.kelly@shopify.com',
|
14
|
+
]
|
12
15
|
|
13
16
|
spec.summary = 'Terminal UI framework extensions'
|
14
17
|
spec.description = 'Terminal UI framework extensions'
|
@@ -16,13 +19,15 @@ Gem::Specification.new do |spec|
|
|
16
19
|
spec.license = 'MIT'
|
17
20
|
|
18
21
|
spec.files = %x(git ls-files -z).split("\x0").reject do |f|
|
19
|
-
f.match(%r{^(test|spec|features)/})
|
22
|
+
f.match(%r{^(sorbet|test|spec|features)/})
|
20
23
|
end
|
21
24
|
spec.bindir = 'exe'
|
22
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
26
|
spec.require_paths = ['lib']
|
24
27
|
|
25
|
-
spec.add_runtime_dependency('cli-ui', '
|
28
|
+
spec.add_runtime_dependency('cli-ui', '~> 2.0')
|
29
|
+
|
30
|
+
spec.required_ruby_version = '>= 3.0'
|
26
31
|
|
27
32
|
spec.add_development_dependency('bundler', '~> 2.1')
|
28
33
|
spec.add_development_dependency('minitest', '~> 5.0')
|
data/dev.yml
CHANGED
@@ -1,7 +1,42 @@
|
|
1
1
|
up:
|
2
|
-
-
|
2
|
+
- homebrew:
|
3
|
+
- fswatch
|
4
|
+
- ruby
|
3
5
|
- bundler
|
4
6
|
|
5
7
|
commands:
|
6
|
-
|
7
|
-
|
8
|
+
add-back-ruby:
|
9
|
+
run: bundle lock --add-platform ruby && git commit -a -m 'Add back ruby platform' && git push
|
10
|
+
aliases: [abr]
|
11
|
+
console: irb -I./lib -rcli/kit
|
12
|
+
check:
|
13
|
+
run: 'srb && rake style test'
|
14
|
+
aliases: [ck]
|
15
|
+
test:
|
16
|
+
run: rake test
|
17
|
+
aliases: [t]
|
18
|
+
style:
|
19
|
+
run: rake style
|
20
|
+
aliases: [st]
|
21
|
+
typecheck:
|
22
|
+
run: srb
|
23
|
+
aliases: [tc]
|
24
|
+
watch:
|
25
|
+
aliases: [w]
|
26
|
+
subcommands:
|
27
|
+
style:
|
28
|
+
run: bin/onchange rake style
|
29
|
+
aliases: [st]
|
30
|
+
test:
|
31
|
+
run: bin/onchange rake test
|
32
|
+
aliases: [t]
|
33
|
+
typecheck:
|
34
|
+
run: bin/onchange srb
|
35
|
+
aliases: [tc]
|
36
|
+
check:
|
37
|
+
run: bin/onchange 'srb && rake style test'
|
38
|
+
aliases: [ck]
|
39
|
+
fastcheck:
|
40
|
+
Test: bundle exec rake test
|
41
|
+
Style: bundle exec rake style
|
42
|
+
Typecheck: bundle exec srb tc
|
data/examples/minimal/example.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# typed: true
|
2
3
|
|
3
4
|
require 'cli/ui'
|
4
5
|
require 'cli/kit'
|
@@ -7,12 +8,16 @@ CLI::UI::StdoutRouter.enable
|
|
7
8
|
|
8
9
|
include(CLI::Kit)
|
9
10
|
|
10
|
-
registry = CommandRegistry.new(default: 'hello'
|
11
|
-
registry.add(
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
registry = CommandRegistry.new(default: 'hello')
|
12
|
+
registry.add(
|
13
|
+
Class.new(BaseCommand) do
|
14
|
+
sig { params(_args: T::Array[String], _name: String).void }
|
15
|
+
def call(_args, _name)
|
16
|
+
puts 'hello, world!'
|
17
|
+
end
|
18
|
+
end,
|
19
|
+
'hello',
|
20
|
+
)
|
16
21
|
|
17
22
|
executor = Executor.new(log_file: '/tmp/example.log')
|
18
23
|
error_handler = ErrorHandler.new(log_file: '/tmp/example.log', exception_reporter: nil)
|