Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add at-main support to invoke LiveServer from the command line. #179

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

fredrikekre
Copy link
Member

Julia 1.11 and later have the option to invoke a package's main function with the -m flag, e.g. julia -m LiveServer <args>.... This patch adds a main function to LiveServer.

Output of julia -m LiveServer --help:

NAME
       LiveServer.main - run a webserver

SYNOPSIS
       julia -m LiveServer [-h <host>] [-p <port>] [-v] [--help] <directory>

DESCRIPTION
       `LiveServer.main` (typically invoked as `julia -m LiveServer`)
       starts a web server serving the contents of the specified
       filesystem directory using the LiveServer.jl Julia package.

OPTIONS
       <directory>
           Path to the root directory of the server (default: pwd)
       -h <host>
           Specify the host (default: 127.0.0.1)
       -p <port>
           Specify the port (default: 8000)
       -v
           Enable verbose output
       --help
           Show this message

Julia 1.11 and later have the option to invoke a package's `main`
function with the `-m` flag, e.g. `julia -m LiveServer <args>...`. This
patch adds a main function to LiveServer.

Output of `julia -m LiveServer --help`:
```
NAME
       LiveServer.main - run a webserver

SYNOPSIS
       julia -m LiveServer [-h <host>] [-p <port>] [-v] [--help] <directory>

DESCRIPTION
       `LiveServer.main` (typically invoked as `julia -m LiveServer`)
       starts a web server serving the contents of the specified
       filesystem directory using the LiveServer.jl Julia package.

OPTIONS
       <directory>
           Path to the root directory of the server (default: pwd)
       -h <host>
           Specify the host (default: 127.0.0.1)
       -p <port>
           Specify the port (default: 8000)
       -v
           Enable verbose output
       --help
           Show this message
```
Copy link
Collaborator

@tlienart tlienart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is very cool, thanks a lot!

@tlienart tlienart merged commit eec3d5b into JuliaDocs:master Apr 10, 2024
3 checks passed
@tlienart
Copy link
Collaborator

might make sense to make the browser launch option default to true in this case? (https://github.com/tlienart/LiveServer.jl/blob/eec3d5b23d16e296ba55c4f99084c1814bee5165/src/server.jl#L613)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants