Move most flags to env vars (#1704)

Env vars provide a more unified experience across
Desktop, Docker, and CLI. We keep only a handful
of switches that mirror Elixir's own CLI.
This commit is contained in:
José Valim 2023-02-10 19:55:47 +01:00 committed by GitHub
parent bf8fc4d064
commit b9e4de68c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -39,22 +39,12 @@ defmodule LivebookCLI.Server do
## Available options ## Available options
--cookie Sets a cookie for the app distributed node --cookie Sets a cookie for the app distributed node
--data-path The directory to store Livebook configuration,
defaults to "livebook" under the default user data directory
--default-runtime Sets the runtime type that is used by default when none is started
explicitly for the given notebook, defaults to standalone
Supported options:
* standalone - Elixir standalone
* attached:NODE:COOKIE - Attached
* embedded - Embedded
--home The home path for the Livebook instance --home The home path for the Livebook instance
--ip The ip address to start the web application on, defaults to 127.0.0.1 --ip The ip address to start the web application on, defaults to 127.0.0.1
Must be a valid IPv4 or IPv6 address Must be a valid IPv4 or IPv6 address
--name Set a name for the app distributed node --name Sets a name for the app distributed node
--no-token Disable token authentication, enabled by default
If LIVEBOOK_PASSWORD is set, it takes precedence over token auth
-p, --port The port to start the web application on, defaults to 8080 -p, --port The port to start the web application on, defaults to 8080
--sname Set a short name for the app distributed node --sname Sets a short name for the app distributed node
The --help option can be given to print this notice. The --help option can be given to print this notice.
@ -197,15 +187,12 @@ defmodule LivebookCLI.Server do
end end
@switches [ @switches [
data_path: :string,
cookie: :string, cookie: :string,
default_runtime: :string,
ip: :string, ip: :string,
name: :string, name: :string,
port: :integer, port: :integer,
home: :string, home: :string,
sname: :string, sname: :string
token: :boolean
] ]
@aliases [ @aliases [
@ -226,14 +213,6 @@ defmodule LivebookCLI.Server do
defp opts_to_config([], config), do: config defp opts_to_config([], config), do: config
defp opts_to_config([{:token, false} | opts], config) do
if Livebook.Config.auth_mode() == :token do
opts_to_config(opts, [{:livebook, :authentication_mode, :disabled} | config])
else
opts_to_config(opts, config)
end
end
defp opts_to_config([{:port, port} | opts], config) do defp opts_to_config([{:port, port} | opts], config) do
opts_to_config(opts, [{:livebook, LivebookWeb.Endpoint, http: [port: port]} | config]) opts_to_config(opts, [{:livebook, LivebookWeb.Endpoint, http: [port: port]} | config])
end end
@ -267,16 +246,6 @@ defmodule LivebookCLI.Server do
opts_to_config(opts, [{:livebook, :cookie, cookie} | config]) opts_to_config(opts, [{:livebook, :cookie, cookie} | config])
end end
defp opts_to_config([{:default_runtime, default_runtime} | opts], config) do
default_runtime = Livebook.Config.default_runtime!("--default-runtime", default_runtime)
opts_to_config(opts, [{:livebook, :default_runtime, default_runtime} | config])
end
defp opts_to_config([{:data_path, path} | opts], config) do
data_path = Livebook.Config.writable_dir!("--data-path", path)
opts_to_config(opts, [{:livebook, :data_path, data_path} | config])
end
defp opts_to_config([_opt | opts], config), do: opts_to_config(opts, config) defp opts_to_config([_opt | opts], config), do: opts_to_config(opts, config)
defp set_path(url, path) do defp set_path(url, path) do