Skip to content

Commit

Permalink
feat(cli): --version flag (#193)
Browse files Browse the repository at this point in the history
This allows you to fetch the version with `nextls --version`
  • Loading branch information
mhanberg authored Aug 20, 2023
1 parent d2db88a commit 8455ba7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/next_ls/lsp_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ defmodule NextLS.LSPSupervisor do
if @env == :test do
:ignore
else
{m, f, a} = if @env == :prod, do: {Burrito.Util.Args, :get_arguments, []}, else: {System, :argv, []}
{m, f, a} =
if @env == :prod, do: {Burrito.Util.Args, :get_arguments, []}, else: {System, :argv, []}

argv = apply(m, f, a)

{opts, _, invalid} =
OptionParser.parse(argv, strict: [stdio: :boolean, port: :integer])
OptionParser.parse(argv, strict: [version: :boolean, stdio: :boolean, port: :integer])

if opts[:version] do
IO.puts("#{NextLS.version()}")
System.halt(0)
end

buffer_opts =
cond do
Expand All @@ -56,7 +62,11 @@ defmodule NextLS.LSPSupervisor do
auto_update =
if "NEXTLS_AUTO_UPDATE" |> System.get_env("false") |> String.to_existing_atom() do
[
binpath: System.get_env("NEXTLS_BINPATH", Path.expand("~/.cache/elixir-tools/nextls/bin/nextls")),
binpath:
System.get_env(
"NEXTLS_BINPATH",
Path.expand("~/.cache/elixir-tools/nextls/bin/nextls")
),
api_host: System.get_env("NEXTLS_GITHUB_API", "https://api.github.com"),
github_host: System.get_env("NEXTLS_GITHUB", "https://github.com"),
current_version: Version.parse!(NextLS.version())
Expand Down

0 comments on commit 8455ba7

Please sign in to comment.