updated cli
added help text and converted options into optional arguments
This commit is contained in:
parent
d1480df28a
commit
0e3e9d243d
1 changed files with 53 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
|||
from typing import Annotated
|
||||
import typer
|
||||
from pathlib import Path
|
||||
from zona import server
|
||||
|
@ -11,20 +12,67 @@ setup_logging("DEBUG")
|
|||
|
||||
|
||||
@app.command()
|
||||
def build(root: Path | None = None, output: Path | None = None):
|
||||
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: Path | None = None, output: Path | None = None):
|
||||
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: Path | None = None):
|
||||
# init will populate the current directory with
|
||||
# the required folders and their default values
|
||||
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)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue