47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
"""Command-line interface for database context extraction jobs."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
from . import schema_snapshot
|
|
|
|
|
|
def parse_args() -> argparse.Namespace:
|
|
parser = argparse.ArgumentParser(
|
|
description="Extract schema and contextual artifacts for the SQL agent.",
|
|
)
|
|
parser.add_argument(
|
|
"--schema",
|
|
default=None,
|
|
help="Optional SQL Server schema to filter on (defaults to all schemas).",
|
|
)
|
|
parser.add_argument(
|
|
"--output",
|
|
default="db_agent/context/schema.json",
|
|
help="Path to write the schema JSON document.",
|
|
)
|
|
parser.add_argument(
|
|
"--job",
|
|
choices=["schema"],
|
|
default="schema",
|
|
help="Extraction job to run (currently only 'schema').",
|
|
)
|
|
return parser.parse_args()
|
|
|
|
|
|
def main() -> None:
|
|
args = parse_args()
|
|
output_path = Path(args.output)
|
|
|
|
if args.job == "schema":
|
|
result = schema_snapshot.run(schema=args.schema, output=output_path)
|
|
print(f"Schema document written to {result}")
|
|
else:
|
|
raise RuntimeError(f"Unsupported job: {args.job}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|