mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-12-18 06:02:45 +08:00
Remove --open-new option when starting server (#960)
This commit is contained in:
parent
51db7b482b
commit
0cae21e9e8
1 changed files with 31 additions and 11 deletions
|
|
@ -15,12 +15,20 @@ defmodule LivebookCLI.Server do
|
||||||
@impl true
|
@impl true
|
||||||
def usage() do
|
def usage() do
|
||||||
"""
|
"""
|
||||||
Usage: livebook server [url] [options]
|
Usage: livebook server [open-command] [--options]
|
||||||
|
|
||||||
An optional url can be given as argument. If one is given,
|
An optional open-command can be given as argument. It will open
|
||||||
a browser window will open importing the given url as a notebook:
|
up a browser window according these rules:
|
||||||
|
|
||||||
livebook server https://example.com/my-notebook.livemd
|
* If the open-command is "new", the browser window will point
|
||||||
|
to a new notebook
|
||||||
|
|
||||||
|
* If the open-command is a URL, the notebook at the given URL
|
||||||
|
will be imported
|
||||||
|
|
||||||
|
The open-command runs after the server is started. If a server is
|
||||||
|
already running, the browser window will point to the server
|
||||||
|
currently running.
|
||||||
|
|
||||||
## Available options
|
## Available options
|
||||||
|
|
||||||
|
|
@ -41,7 +49,6 @@ defmodule LivebookCLI.Server do
|
||||||
--no-token Disable token authentication, enabled by default
|
--no-token Disable token authentication, enabled by default
|
||||||
If LIVEBOOK_PASSWORD is set, it takes precedence over token auth
|
If LIVEBOOK_PASSWORD is set, it takes precedence over token auth
|
||||||
--open Open browser window pointing to the application
|
--open Open browser window pointing to the application
|
||||||
--open-new Open browser window pointing to a new notebook
|
|
||||||
-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
|
||||||
--root-path The root path to use for file selection
|
--root-path The root path to use for file selection
|
||||||
--sname Set a short name for the app distributed node
|
--sname Set a short name for the app distributed node
|
||||||
|
|
@ -52,6 +59,20 @@ defmodule LivebookCLI.Server do
|
||||||
|
|
||||||
#{@environment_variables}
|
#{@environment_variables}
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
Starts a server:
|
||||||
|
|
||||||
|
livebook server
|
||||||
|
|
||||||
|
Starts a server and opens up a browser at a new notebook:
|
||||||
|
|
||||||
|
livebook server new
|
||||||
|
|
||||||
|
Starts a server and imports the notebook at the given URL:
|
||||||
|
|
||||||
|
livebook server https://example.com/my-notebook.livemd
|
||||||
|
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -125,12 +146,12 @@ defmodule LivebookCLI.Server do
|
||||||
if opts[:open] do
|
if opts[:open] do
|
||||||
Livebook.Utils.browser_open(base_url)
|
Livebook.Utils.browser_open(base_url)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if opts[:open_new] do
|
defp open_from_options(base_url, _opts, ["new"]) do
|
||||||
base_url
|
base_url
|
||||||
|> append_path("/explore/notebooks/new")
|
|> append_path("/explore/notebooks/new")
|
||||||
|> Livebook.Utils.browser_open()
|
|> Livebook.Utils.browser_open()
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp open_from_options(base_url, _opts, [url]) do
|
defp open_from_options(base_url, _opts, [url]) do
|
||||||
|
|
@ -152,7 +173,6 @@ defmodule LivebookCLI.Server do
|
||||||
ip: :string,
|
ip: :string,
|
||||||
name: :string,
|
name: :string,
|
||||||
open: :boolean,
|
open: :boolean,
|
||||||
open_new: :boolean,
|
|
||||||
port: :integer,
|
port: :integer,
|
||||||
root_path: :string,
|
root_path: :string,
|
||||||
sname: :string,
|
sname: :string,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue