Skip to content

Commit a5afbe2

Browse files
alpaca-tcmame
authored andcommitted
fix: Resolve issue preventing CLI startup with typeprof --lsp --stdio option
This commit fixes a bug where the CLI would fail to start when invoked with the `typeprof --lsp --stdio` option.
1 parent 4260c32 commit a5afbe2

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

lib/typeprof/cli/cli.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def initialize(argv)
4949

5050
opt.parse!(argv)
5151

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

test/cli_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,23 @@ def check: -> :ok
110110
end
111111
end)
112112
end
113+
114+
def test_lsp_options_with_lsp_mode
115+
assert_nothing_raised { TypeProf::CLI::CLI.new(["--lsp", "--stdio"]) }
116+
end
117+
118+
def test_lsp_options_with_non_lsp_mode
119+
invalid_options = [
120+
["--stdio", "."],
121+
["--port", "123456", "."],
122+
]
123+
124+
invalid_options.each do |argv|
125+
stdout, _stderr = capture_output do
126+
assert_raises(SystemExit) { TypeProf::CLI::CLI.new(argv) }
127+
end
128+
assert_equal("invalid option: lsp options with non-lsp mode\n", stdout)
129+
end
130+
end
113131
end
114132
end

0 commit comments

Comments
 (0)