Skip to content

Commit 8455ba7

Browse files
authored
feat(cli): --version flag (#193)
This allows you to fetch the version with `nextls --version`
1 parent d2db88a commit 8455ba7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lib/next_ls/lsp_supervisor.ex

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@ defmodule NextLS.LSPSupervisor do
3333
if @env == :test do
3434
:ignore
3535
else
36-
{m, f, a} = if @env == :prod, do: {Burrito.Util.Args, :get_arguments, []}, else: {System, :argv, []}
36+
{m, f, a} =
37+
if @env == :prod, do: {Burrito.Util.Args, :get_arguments, []}, else: {System, :argv, []}
3738

3839
argv = apply(m, f, a)
3940

4041
{opts, _, invalid} =
41-
OptionParser.parse(argv, strict: [stdio: :boolean, port: :integer])
42+
OptionParser.parse(argv, strict: [version: :boolean, stdio: :boolean, port: :integer])
43+
44+
if opts[:version] do
45+
IO.puts("#{NextLS.version()}")
46+
System.halt(0)
47+
end
4248

4349
buffer_opts =
4450
cond do
@@ -56,7 +62,11 @@ defmodule NextLS.LSPSupervisor do
5662
auto_update =
5763
if "NEXTLS_AUTO_UPDATE" |> System.get_env("false") |> String.to_existing_atom() do
5864
[
59-
binpath: System.get_env("NEXTLS_BINPATH", Path.expand("~/.cache/elixir-tools/nextls/bin/nextls")),
65+
binpath:
66+
System.get_env(
67+
"NEXTLS_BINPATH",
68+
Path.expand("~/.cache/elixir-tools/nextls/bin/nextls")
69+
),
6070
api_host: System.get_env("NEXTLS_GITHUB_API", "https://api.github.com"),
6171
github_host: System.get_env("NEXTLS_GITHUB", "https://github.com"),
6272
current_version: Version.parse!(NextLS.version())

0 commit comments

Comments
 (0)