Skip to content

Commit

Permalink
feat: Add the -r option to the standalone HTML generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuestengecko committed Nov 30, 2023
1 parent 2ef35b7 commit 588bb05
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions capella_diff_tools/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,18 @@ def generate_html(data: types.ChangeSummaryDocument) -> Markup:


@click.command()
@click.argument("filename")
def main(filename):
with open(filename, encoding="locale") as f:
data = yaml.load(f, Loader=_CustomLoader)
@click.argument("filename", type=click.File("r"))
@click.option(
"-r",
"--report",
"report_file",
type=click.File("w"),
help="Write the HTML report to this file",
)
def main(filename: t.IO[str], report_file: t.IO[str]) -> None:
data = yaml.load(filename, Loader=_CustomLoader)
html = generate_html(data)
with open("report.html", "w", encoding="locale") as f:
f.write(html)
report_file.write(html)


if __name__ == "__main__":
Expand Down

0 comments on commit 588bb05

Please sign in to comment.