api/flake/add: init

Adds an endpoint to memoize clans.
clan flakes can be added to the history either via the endpoint or by executing `clan flakes add`
This commit is contained in:
DavHau
2023-11-17 17:05:15 +07:00
parent 7044774567
commit 11fb73432b
6 changed files with 90 additions and 1 deletions

View File

@@ -17,7 +17,7 @@ from clan_cli.webui.api_outputs import (
)
from ...async_cmd import run
from ...flakes import create
from ...flakes import add, create
from ...nix import nix_command, nix_flake_show
from ..tags import Tags
@@ -45,6 +45,11 @@ async def get_attrs(url: AnyUrl | Path) -> list[str]:
return flake_attrs
@router.put("/api/flake/add", tags=[Tags.flake])
async def add_flake(flake_dir: Path) -> None:
await add.add_flake(flake_dir)
# TODO: Check for directory traversal
@router.get("/api/flake/attrs", tags=[Tags.flake])
async def inspect_flake_attrs(url: AnyUrl | Path) -> FlakeAttrResponse: