from-markdown takes a hand-written summary such as SUMMARY.md and sets it in the full report's dress: the same cover, header, footers, table of contents, headings and grids. The shared macros move to macros.html.j2 so both templates draw from them, and layout.render_pdf takes the template and document title to use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
"""Entrypoint for the report generator CLI."""
|
|
|
|
from .vendor.cc_common.api.cli import CLIManager
|
|
from .vendor.cc_common.config import load_environment
|
|
from .vendor.persistent_storage.shared import inject_secrets
|
|
|
|
from .commands.generate import FolderProperties, GenerateProperties, from_folder, generate
|
|
from .commands.summary import SummaryProperties, from_markdown
|
|
|
|
|
|
def run() -> None:
|
|
"""Entrypoint for CLI."""
|
|
load_environment()
|
|
|
|
cli = CLIManager("report_generator", "Generates the PDF report of a scan.")
|
|
|
|
cli.register_command(
|
|
"generate",
|
|
_with_storage_secrets,
|
|
GenerateProperties,
|
|
help="Builds the report of a scan held in the store.",
|
|
)
|
|
cli.register_command(
|
|
"from-folder",
|
|
from_folder,
|
|
FolderProperties,
|
|
help="Builds the report from a folder of exported artifacts, without Postgres or the bucket.",
|
|
)
|
|
cli.register_command(
|
|
"from-markdown",
|
|
from_markdown,
|
|
SummaryProperties,
|
|
help="Builds a summary report from a Markdown file, in the style of the full report.",
|
|
)
|
|
cli.run()
|
|
|
|
|
|
def _with_storage_secrets(properties: GenerateProperties) -> object:
|
|
"""Fill the storage configuration's secrets from the environment before the command runs."""
|
|
inject_secrets(properties.storage_config)
|
|
|
|
return generate(properties)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run()
|