Add gated changeset application and graph controls
This commit is contained in:
parent
3c15e26283
commit
78335c8973
20 changed files with 1813 additions and 453 deletions
|
|
@ -5,13 +5,16 @@ from __future__ import annotations
|
|||
import argparse
|
||||
import json
|
||||
import sys
|
||||
import webbrowser
|
||||
from pathlib import Path
|
||||
|
||||
from .application import CanonicalApplicationService, GenericCanonicalApplier
|
||||
from .context import compile_context
|
||||
from .errors import DocForgeError
|
||||
from .index import ProjectIndex
|
||||
from .project import Project, project_root_fingerprint
|
||||
from .rendering import RenderService
|
||||
from .viewer_manager import ViewerManagerClient
|
||||
|
||||
|
||||
def _parser() -> argparse.ArgumentParser:
|
||||
|
|
@ -21,6 +24,7 @@ def _parser() -> argparse.ArgumentParser:
|
|||
commands.add_parser("info")
|
||||
commands.add_parser("validate")
|
||||
commands.add_parser("build")
|
||||
commands.add_parser("reindex")
|
||||
commands.add_parser("check")
|
||||
commands.add_parser("validate-index")
|
||||
show = commands.add_parser("show")
|
||||
|
|
@ -51,6 +55,18 @@ def _parser() -> argparse.ArgumentParser:
|
|||
preview = commands.add_parser("preview")
|
||||
preview.add_argument("changeset_id")
|
||||
preview.add_argument("view_id")
|
||||
apply_command = commands.add_parser("apply")
|
||||
apply_command.add_argument("changeset_id")
|
||||
apply_command.add_argument("--changeset-hash", required=True)
|
||||
apply_command.add_argument("--applier", required=True)
|
||||
visualize = commands.add_parser("visualize")
|
||||
target = visualize.add_mutually_exclusive_group()
|
||||
target.add_argument("--node")
|
||||
target.add_argument("--query")
|
||||
visualize.add_argument("--depth", type=int, default=1)
|
||||
visualize.add_argument("--no-open", action="store_true")
|
||||
commands.add_parser("visualization-status")
|
||||
commands.add_parser("visualization-stop")
|
||||
return parser
|
||||
|
||||
|
||||
|
|
@ -84,6 +100,13 @@ def _run(arguments: argparse.Namespace) -> dict[str, object]:
|
|||
}
|
||||
if arguments.command == "build":
|
||||
return index.build()
|
||||
if arguments.command == "reindex":
|
||||
built = index.build()
|
||||
return {
|
||||
**built,
|
||||
"reindexed": True,
|
||||
"check": index.check(),
|
||||
}
|
||||
if arguments.command == "check":
|
||||
return index.check()
|
||||
if arguments.command == "validate-index":
|
||||
|
|
@ -114,6 +137,33 @@ def _run(arguments: argparse.Namespace) -> dict[str, object]:
|
|||
return RenderService(project).status(arguments.view_id)
|
||||
if arguments.command == "preview":
|
||||
return RenderService(project).preview(arguments.changeset_id, arguments.view_id)
|
||||
if arguments.command == "apply":
|
||||
return CanonicalApplicationService(
|
||||
project,
|
||||
applier_id=arguments.applier,
|
||||
applier=GenericCanonicalApplier(project),
|
||||
).apply(arguments.changeset_id, arguments.changeset_hash)
|
||||
if arguments.command == "visualize":
|
||||
visualization = ViewerManagerClient(index).start(
|
||||
node_id=arguments.node,
|
||||
query=arguments.query,
|
||||
depth=arguments.depth,
|
||||
)
|
||||
opened = False
|
||||
if not arguments.no_open:
|
||||
opened = webbrowser.open(str(visualization["url"]))
|
||||
return {
|
||||
"status": "ok",
|
||||
"project_id": project.descriptor.project_id,
|
||||
"project_root_fingerprint": project_root_fingerprint(project.descriptor.root),
|
||||
"adapter": project.descriptor.adapter,
|
||||
"opened_browser": opened,
|
||||
"visualization": visualization,
|
||||
}
|
||||
if arguments.command == "visualization-status":
|
||||
return ViewerManagerClient(index).status()
|
||||
if arguments.command == "visualization-stop":
|
||||
return ViewerManagerClient(index).stop()
|
||||
raise DocForgeError("invalid_command", "Unknown command")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue