-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
39 lines (31 loc) · 912 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import click
from utils.auditor import Auditor
from utils.repository import Repository
@click.group()
def cli():
"""Command scripts."""
pass
@cli.command()
@click.argument("github_repo_link")
def audit(github_repo_link):
"""Audit a GitHub repo."""
repo = Repository(github_repo_link)
auditor = Auditor(repo)
auditor.audit()
@cli.command()
@click.argument("single_file")
def audit_file(single_file):
"""Audit a single file."""
auditor = Auditor()
# Load the single file in text and analyze it.
with open(single_file, "r") as f:
content = f.read()
analysis = auditor.analyze_code(content)
analyses = {single_file: analysis}
audit_report = auditor.create_audit_report(analyses)
# Write audit_report to file.
with open("audit_report.md", "w") as f:
f.write(audit_report)
print(audit_report)
if __name__ == "__main__":
cli()