diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 4dd7fb9b..1df6f23c 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -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: diff --git a/.ruby-version b/.ruby-version index 15a27998..6cb9d3dd 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.3.0 +3.4.3 diff --git a/Gemfile.lock b/Gemfile.lock index 01136d57..9a4fcf79 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 @@ -29,22 +29,22 @@ 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) @@ -52,39 +52,43 @@ GEM 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) @@ -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) @@ -107,10 +112,8 @@ GEM yard PLATFORMS - arm64-darwin-21 + aarch64-linux universal-darwin - x64-mingw-ucrt - x64-mingw32 x86_64-linux DEPENDENCIES @@ -132,4 +135,4 @@ DEPENDENCIES tapioca BUNDLED WITH - 2.4.9 + 2.6.7 diff --git a/dev.yml b/dev.yml index 491ca41d..56b23c7c 100644 --- a/dev.yml +++ b/dev.yml @@ -1,5 +1,7 @@ +nix: true + up: - - homebrew: + - packages: - fswatch - ruby - bundler diff --git a/lib/cli/kit/args/evaluation.rb b/lib/cli/kit/args/evaluation.rb index e74bb772..ef6ce2ca 100644 --- a/lib/cli/kit/args/evaluation.rb +++ b/lib/cli/kit/args/evaluation.rb @@ -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 diff --git a/lib/cli/kit/command_help.rb b/lib/cli/kit/command_help.rb index cf691553..7ee02eff 100644 --- a/lib/cli/kit/command_help.rb +++ b/lib/cli/kit/command_help.rb @@ -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 diff --git a/lib/cli/kit/error_handler.rb b/lib/cli/kit/error_handler.rb index 5f59bf10..a591b17f 100644 --- a/lib/cli/kit/error_handler.rb +++ b/lib/cli/kit/error_handler.rb @@ -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 diff --git a/lib/cli/kit/opts.rb b/lib/cli/kit/opts.rb index e7c163c6..18b50d98 100644 --- a/lib/cli/kit/opts.rb +++ b/lib/cli/kit/opts.rb @@ -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 @@ -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 @@ -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| @@ -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| diff --git a/test/cli/kit/parse_args_test.rb b/test/cli/kit/parse_args_test.rb index 7014eb3a..e07b83d8 100644 --- a/test/cli/kit/parse_args_test.rb +++ b/test/cli/kit/parse_args_test.rb @@ -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', ) diff --git a/test/cli/kit/support/test_helper_test.rb b/test/cli/kit/support/test_helper_test.rb index e6adc6de..02e073c3 100644 --- a/test/cli/kit/support/test_helper_test.rb +++ b/test/cli/kit/support/test_helper_test.rb @@ -34,8 +34,9 @@ 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 @@ -43,11 +44,11 @@ def test_when_commands_not_run_correctly 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