Skip to content

Commit

Permalink
fix: Resolve issue preventing CLI startup with `typeprof --lsp --stdi…
Browse files Browse the repository at this point in the history
…o` option

This commit fixes a bug where the CLI would fail to start when invoked with
the `typeprof --lsp --stdio` option.
  • Loading branch information
alpaca-tc authored and mame committed Dec 17, 2024
1 parent 4260c32 commit a5afbe2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/typeprof/cli/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def initialize(argv)

opt.parse!(argv)

if cli_options[:lsp] && !lsp_options.empty?
if !cli_options[:lsp] && !lsp_options.empty?
raise OptionParser::InvalidOption.new("lsp options with non-lsp mode")
end

Expand Down
18 changes: 18 additions & 0 deletions test/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,23 @@ def check: -> :ok
end
end)
end

def test_lsp_options_with_lsp_mode
assert_nothing_raised { TypeProf::CLI::CLI.new(["--lsp", "--stdio"]) }
end

def test_lsp_options_with_non_lsp_mode
invalid_options = [
["--stdio", "."],
["--port", "123456", "."],
]

invalid_options.each do |argv|
stdout, _stderr = capture_output do
assert_raises(SystemExit) { TypeProf::CLI::CLI.new(argv) }
end
assert_equal("invalid option: lsp options with non-lsp mode\n", stdout)
end
end
end
end

0 comments on commit a5afbe2

Please sign in to comment.