updated cli serve interface

This commit is contained in:
Daniel Fichtinger 2025-07-06 15:35:12 -04:00
parent cefd57d8d7
commit 3b32352ba6

View file

@ -59,9 +59,7 @@ def build(
""" """
if draft: if draft:
print("Option override: including drafts.") print("Option override: including drafts.")
builder = ZonaBuilder( builder = ZonaBuilder(cli_root=root, cli_output=output, draft=draft)
cli_root=root, cli_output=output, draft=draft
)
builder.build() builder.build()
@ -73,6 +71,16 @@ def serve(
help="Directory containing config.yml", help="Directory containing config.yml",
), ),
] = None, ] = None,
host: Annotated[
str,
typer.Option("--host", help="Hostname for live preview server."),
] = "localhost",
port: Annotated[
int,
typer.Option(
"--port", "-p", help="Port number for live preview server."
),
] = 8000,
output: Annotated[ output: Annotated[
Path | None, Path | None,
typer.Option( typer.Option(
@ -83,6 +91,14 @@ def serve(
bool, bool,
typer.Option("--draft", "-d", help="Include drafts."), typer.Option("--draft", "-d", help="Include drafts."),
] = False, ] = False,
no_live_reload: Annotated[
bool,
typer.Option(
"--no-live-reload",
"-n",
help="Don't automatically reload web preview.",
),
] = False,
): ):
""" """
Build the website and start a live preview server. Build the website and start a live preview server.
@ -93,7 +109,14 @@ def serve(
""" """
if draft: if draft:
print("Option override: including drafts.") print("Option override: including drafts.")
server.serve(root, output, draft) server.serve(
root=root,
output=output,
draft=draft,
host=host,
port=port,
live_reload=not no_live_reload,
)
@app.callback() @app.callback()