Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
ruby-version: ['3.1', '3.2', '3.3']
os: [macos-latest, ubuntu-latest]
ruby-version: ['3.1', '3.2', '3.3', '3.4']

runs-on: ${{ matrix.os }}
env:
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
3.4.3
81 changes: 42 additions & 39 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ GEM
remote: https://rubygems.org/
specs:
ansi (1.5.0)
ast (2.4.2)
benchmark (0.4.0)
ast (2.4.3)
benchmark (0.4.1)
builder (3.3.0)
byebug (11.1.3)
cli-ui (2.3.0)
byebug (12.0.0)
cli-ui (2.3.1)
docile (1.4.1)
erubi (1.13.1)
json (2.10.1)
language_server-protocol (3.17.0.4)
json (2.13.2)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
logger (1.6.6)
logger (1.7.0)
method_source (1.1.0)
minitest (5.25.4)
minitest (5.25.5)
minitest-reporters (1.7.1)
ansi
builder
Expand All @@ -29,62 +29,66 @@ GEM
mocha (2.4.5)
ruby2_keywords (>= 0.0.5)
netrc (0.11.0)
parallel (1.26.3)
parser (3.3.7.1)
parallel (1.27.0)
parser (3.3.9.0)
ast (~> 2.4.1)
racc
prism (1.3.0)
prism (1.4.0)
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
rbi (0.3.0)
rake (13.3.0)
rbi (0.3.6)
prism (~> 1.0)
rbs (>= 3.4.4)
sorbet-runtime (>= 0.5.9204)
rbs (3.8.1)
rbs (3.9.4)
logger
regexp_parser (2.10.0)
rubocop (1.73.2)
rexml (3.4.1)
rubocop (1.79.0)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-ast (>= 1.46.0, < 2.0)
ruby-progressbar (~> 1.7)
tsort (>= 0.2.0)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.38.1)
parser (>= 3.3.1.0)
rubocop-ast (1.46.0)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-rake (0.7.1)
lint_roller (~> 1.1)
rubocop (>= 1.72.1)
rubocop-shopify (2.16.0)
rubocop-shopify (2.17.1)
rubocop (~> 1.62)
rubocop-sorbet (0.9.0)
lint_roller (~> 1.1)
rubocop (>= 1)
rubocop-sorbet (0.10.5)
lint_roller
rubocop (>= 1.75.2)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.1)
simplecov-html (0.13.2)
simplecov_json_formatter (0.1.4)
sorbet (0.5.11915)
sorbet-static (= 0.5.11915)
sorbet-runtime (0.5.11915)
sorbet-static (0.5.11915-universal-darwin)
sorbet-static (0.5.11915-x86_64-linux)
sorbet-static-and-runtime (0.5.11915)
sorbet (= 0.5.11915)
sorbet-runtime (= 0.5.11915)
spoom (1.5.4)
sorbet (0.5.12358)
sorbet-static (= 0.5.12358)
sorbet-runtime (0.5.12358)
sorbet-static (0.5.12358-aarch64-linux)
sorbet-static (0.5.12358-universal-darwin)
sorbet-static (0.5.12358-x86_64-linux)
sorbet-static-and-runtime (0.5.12358)
sorbet (= 0.5.12358)
sorbet-runtime (= 0.5.12358)
spoom (1.6.3)
erubi (>= 1.10.0)
prism (>= 0.28.0)
rbi (>= 0.2.3)
rbi (>= 0.3.3)
rexml (>= 3.2.6)
sorbet-static-and-runtime (>= 0.5.10187)
thor (>= 0.19.2)
tapioca (0.16.11)
Expand All @@ -97,7 +101,8 @@ GEM
spoom (>= 1.2.0)
thor (>= 1.2.0)
yard-sorbet
thor (1.3.2)
thor (1.4.0)
tsort (0.2.0)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
Expand All @@ -107,10 +112,8 @@ GEM
yard

PLATFORMS
arm64-darwin-21
aarch64-linux
universal-darwin
x64-mingw-ucrt
x64-mingw32
x86_64-linux

DEPENDENCIES
Expand All @@ -132,4 +135,4 @@ DEPENDENCIES
tapioca

BUNDLED WITH
2.4.9
2.6.7
4 changes: 3 additions & 1 deletion dev.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
nix: true

up:
- homebrew:
- packages:
- fswatch
- ruby
- bundler
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/kit/args/evaluation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def lookup_option(opt)
)
matches = opts.select { |node| (opt.short && node.name == opt.short) || (opt.long && node.name == opt.long) }
if (last = matches.last)
return(opt.multi? ? matches.map(&:value) : last.value)
return (opt.multi? ? matches.map(&:value) : last.value)
end

opt.default
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/kit/command_help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def opts_class
sig { returns(T.nilable(String)) }
def build_options
opts = opts_class
return(nil) unless opts
return unless opts

methods = []
loop do
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/kit/error_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ def triage_all_exceptions(&block)
sig { params(error: T.nilable(Exception)).returns(T.nilable(Exception)) }
def exception_for_submission(error)
# happens on normal non-error termination
return(nil) if error.nil?
return if error.nil?

return(nil) unless error.bug?
return unless error.bug?

case error
when SignalException
Expand Down
13 changes: 10 additions & 3 deletions lib/cli/kit/opts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ def rest(name: infer_name, desc: nil)

private

sig { params(label: T.nilable(String)).returns(T.nilable(Symbol)) }
def symbolize(label)
return if label.nil?

label.split('#').last&.to_sym
end

sig { returns(Symbol) }
def infer_name
to_skip = 1
Expand All @@ -190,7 +197,7 @@ def infer_name
to_skip -= 1
next
end
return(T.must(loc.label&.to_sym))
return T.must(symbolize(loc.label))
end
raise(ArgumentError, 'could not infer name')
end
Expand Down Expand Up @@ -218,7 +225,7 @@ def unparsed
).returns(T.untyped)
end
def each_option(&block)
return(enum_for(:each_option)) unless block_given?
return enum_for(:each_option) unless block_given?

obj = assert_result!
obj.defn.options.each do |opt|
Expand All @@ -236,7 +243,7 @@ def each_option(&block)
).returns(T.untyped)
end
def each_flag(&block)
return(enum_for(:each_flag)) unless block_given?
return enum_for(:each_flag) unless block_given?

obj = assert_result!
obj.defn.flags.each do |flag|
Expand Down
1 change: 0 additions & 1 deletion test/cli/kit/parse_args_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def test_options_long
end

def test_options_multi
# rubocop:disable Layout/LineLength
@cmd.call(
'--maybe --choice --count 100 --sum 111 --val bar --str baz --opt other_val --snake-squad-alpha cobras --count 200 --opt france --opt',
)
Expand Down
9 changes: 5 additions & 4 deletions test/cli/kit/support/test_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,21 @@ def test_when_commands_not_run_correctly
CLI::Kit::System.fake('banana', success: true)
CLI::Kit::System.fake('kiwi', success: true)

CLI::Kit::System.system('banana', sudo: true, env: { kiwi: false })
CLI::Kit::System.system('kiwi', sudo: true, env: { kiwi: false })
env = { kiwi: false }
CLI::Kit::System.system('banana', sudo: true, env: env)
CLI::Kit::System.system('kiwi', sudo: true, env: env)

errors = assert_all_commands_run(should_raise: false)
expected_err = <<~EOF

Commands were not run as expected:
banana
- sudo was supposed to be false but was true
- env was supposed to be {} but was {:kiwi=>false}
- env was supposed to be {} but was #{env}

kiwi
- sudo was supposed to be false but was true
- env was supposed to be {} but was {:kiwi=>false}
- env was supposed to be {} but was #{env}
EOF
assert_equal(expected_err, CLI::UI::ANSI.strip_codes(errors))
end
Expand Down
Loading