zona/src/zona/cli.py
Daniel Fichtinger 0e3e9d243d updated cli
added help text and converted options into optional arguments
2025-07-02 13:46:32 -04:00

80 lines
1.6 KiB
Python

from typing import Annotated
import typer
from pathlib import Path
from zona import server
from zona.builder import ZonaBuilder
from zona.layout import initialize_site
from zona.log import setup_logging
app = typer.Typer()
setup_logging("DEBUG")
@app.command()
def build(
root: Annotated[
Path | None,
typer.Argument(
help="Directory containing config.yml",
),
] = None,
output: Annotated[
Path | None,
typer.Argument(help="Location to write built website"),
] = None,
):
"""
Build the website.
Optionally specify the ROOT and OUTPUT directories.
"""
builder = ZonaBuilder(root, output)
builder.build()
@app.command()
def serve(
root: Annotated[
Path | None,
typer.Argument(
help="Directory containing config.yml",
),
] = None,
output: Annotated[
Path | None,
typer.Argument(help="Location to write built website"),
] = None,
):
"""
Build the website and start a live preview server.
The website is rebuilt when the source is modified.
Optionally specify the ROOT and OUTPUT directories.
"""
server.serve(root, output)
@app.command()
def init(
root: Annotated[
Path | None,
typer.Argument(
help="Target directory to populate as a Zona project",
),
] = None,
):
"""
Initialize a Zona website project.
The required directory structure is created,
and the default configuration file is included.
Optionally specify the ROOT directory.
"""
initialize_site(root)
def main():
app()