generated from coulomb/repo-seed
entity relationship model
This commit is contained in:
@@ -8,6 +8,7 @@ from pathlib import Path
|
||||
from .errors import InfospaceError
|
||||
from .lifecycle import add_artifact, create_infospace, load_infospace
|
||||
from .markdown_adapter import validate_infospace_artifacts
|
||||
from .semantics import list_entities, list_relations
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
@@ -35,6 +36,12 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
validate = sub.add_parser("validate", help="Validate infospace artifacts")
|
||||
validate.add_argument("root")
|
||||
|
||||
entities = sub.add_parser("entities", help="List parsed entity artifacts")
|
||||
entities.add_argument("root")
|
||||
|
||||
relations = sub.add_parser("relations", help="List parsed relation artifacts")
|
||||
relations.add_argument("root")
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
@@ -72,6 +79,23 @@ def main(argv: list[str] | None = None) -> int:
|
||||
}
|
||||
)
|
||||
return 0 if valid else 1
|
||||
elif args.command == "entities":
|
||||
_write_json(
|
||||
{
|
||||
"entities": [
|
||||
entity.to_dict() for entity in list_entities(Path(args.root))
|
||||
]
|
||||
}
|
||||
)
|
||||
elif args.command == "relations":
|
||||
_write_json(
|
||||
{
|
||||
"relations": [
|
||||
relation.to_dict()
|
||||
for relation in list_relations(Path(args.root))
|
||||
]
|
||||
}
|
||||
)
|
||||
else:
|
||||
parser.error(f"Unhandled command: {args.command}")
|
||||
except InfospaceError as exc:
|
||||
|
||||
Reference in New Issue
Block a user