JuliaDocs / LiveServer.jl

Simple development server with live-reload capability for Julia.
MIT License
143 stars 26 forks source link

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

Closed fredrikekre closed 6 months ago

fredrikekre commented 6 months ago

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
tlienart commented 6 months ago

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)