feat(knowledge-gap): add CLI entry point for monthly execution (Closes #172)
Some checks failed
Test / pytest (pull_request) Failing after 8s
Some checks failed
Test / pytest (pull_request) Failing after 8s
- Adds main() with argparse for repo_path, --json, --output flags - Enables scheduled monthly execution via cron - Fixes to_dict() stats keys to use string values for JSON serialization
This commit is contained in:
@@ -75,7 +75,7 @@ class GapReport:
|
|||||||
return {
|
return {
|
||||||
"repo_path": self.repo_path,
|
"repo_path": self.repo_path,
|
||||||
"total_gaps": len(self.gaps),
|
"total_gaps": len(self.gaps),
|
||||||
"stats": {k: len(v) for k, v in
|
"stats": {k.value: len(v) for k, v in
|
||||||
{gt: [g for g in self.gaps if g.gap_type == gt]
|
{gt: [g for g in self.gaps if g.gap_type == gt]
|
||||||
for gt in GapType}.items() if v},
|
for gt in GapType}.items() if v},
|
||||||
"gaps": [
|
"gaps": [
|
||||||
@@ -273,3 +273,44 @@ class KnowledgeGapIdentifier:
|
|||||||
))
|
))
|
||||||
|
|
||||||
return report
|
return report
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Knowledge Gap Identifier — cross-reference code, docs, and tests to find gaps"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"repo_path",
|
||||||
|
nargs="?",
|
||||||
|
default=".",
|
||||||
|
help="Path to repository root (default: current directory)"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--json",
|
||||||
|
action="store_true",
|
||||||
|
help="Output report as JSON instead of human-readable summary"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-o", "--output",
|
||||||
|
help="Write report to file instead of stdout"
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
report = KnowledgeGapIdentifier().analyze(args.repo_path)
|
||||||
|
|
||||||
|
if args.json:
|
||||||
|
output = json.dumps(report.to_dict(), indent=2, default=str)
|
||||||
|
else:
|
||||||
|
output = report.summary()
|
||||||
|
|
||||||
|
if args.output:
|
||||||
|
with open(args.output, "w") as fh:
|
||||||
|
print(output, file=fh)
|
||||||
|
else:
|
||||||
|
print(output)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user