diff --git a/src/zona/cli.py b/src/zona/cli.py index bbfc612..3d583f0 100644 --- a/src/zona/cli.py +++ b/src/zona/cli.py @@ -8,53 +8,6 @@ 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( @@ -76,5 +29,73 @@ def init( initialize_site(root) +@app.command() +def build( + root: Annotated[ + Path | None, + typer.Argument( + help="Directory containing config.yml", + ), + ] = None, + output: Annotated[ + Path | None, + typer.Option( + "--output", "-o", 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.Option( + "--output", "-o", 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.callback() +def main_entry( + verbosity: Annotated[ + str, + typer.Option( + "--verbosity", + "-v", + help="Logging verbosity. One of INFO, DEBUG, WARN, ERROR.", + ), + ] = "info", +) -> None: + """ + Opinionated static site generator. + + Supply --help after any subcommand for more details. + """ + setup_logging(verbosity) + + def main(): app() diff --git a/src/zona/log.py b/src/zona/log.py index f3a3f25..129a36c 100644 --- a/src/zona/log.py +++ b/src/zona/log.py @@ -6,7 +6,7 @@ _LOGGER_NAME = "zona" def setup_logging( - level: Literal["INFO", "DEBUG", "WARN", "ERROR"] = "INFO", + level: str = "INFO", ): logger = logging.getLogger(_LOGGER_NAME) logger.setLevel(level.upper())