50 lines
1.1 KiB
Python
50 lines
1.1 KiB
Python
import click
|
|
import pydantic
|
|
|
|
from .build import build_site
|
|
from .nextcloud import NextCloudClient
|
|
from .renderer import JinjaDocumentRenderer
|
|
|
|
|
|
class ApiContext(pydantic.BaseModel):
|
|
"""
|
|
Contextual information to connect to the remote document store.
|
|
"""
|
|
|
|
user: str
|
|
pwd: str
|
|
base_url: str
|
|
|
|
|
|
class Context(pydantic.BaseModel):
|
|
"""Tool's context data."""
|
|
|
|
api: ApiContext
|
|
|
|
|
|
@click.group()
|
|
@click.option("--user", "-u", type=str, required=True)
|
|
@click.option("--password", "-p", type=str, required=True)
|
|
@click.option("--host", "-H", type=str, required=True)
|
|
@click.pass_context
|
|
def cli(ctx, user: str, password: str, host: str):
|
|
"""Tool entrypoint."""
|
|
ctx.obj = Context(api=ApiContext(user=user, pwd=password, base_url=host))
|
|
|
|
|
|
@cli.command()
|
|
@click.pass_obj
|
|
def build(ctx):
|
|
"""Build command - pieces static assets together."""
|
|
client = NextCloudClient(
|
|
base_url=ctx.api.base_url, password=ctx.api.pwd, user=ctx.api.user
|
|
)
|
|
build_site(client=client, renderer=JinjaDocumentRenderer())
|
|
|
|
|
|
def main():
|
|
cli()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|