Skip to content

Commit

Permalink
Add --title parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Sylvain Hellegouarch <sh@defuze.org>
  • Loading branch information
Lawouach committed Jan 5, 2024
1 parent 6fb36ad commit b0b8cec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

## [Unreleased][]

[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-reporting/compare/0.16.0...HEAD
[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-reporting/compare/0.17.0...HEAD

## [0.17.0][] - 2024-01-05

[0.17.0]: https://github.com/chaostoolkit/chaostoolkit-reporting/compare/0.16.0...0.17.0

### Added

- The `--title` option to the `report` command so you can force the title
in the report header

## [0.16.0][] - 2023-12-05

Expand Down
8 changes: 5 additions & 3 deletions chaosreport/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"generate_report_header",
"save_report",
]
__version__ = "0.16.0"
__version__ = "0.17.0"

curdir = os.getcwd()
basedir = os.path.dirname(__file__)
Expand All @@ -43,12 +43,14 @@


def generate_report_header(
journal_paths: List[str], export_format: str = "markdown"
journal_paths: List[str],
export_format: str = "markdown",
title: str = None,
) -> str:
header_template = get_report_template(None, "header.md")

header_info = {}
header_info["title"] = "Chaos Engineering Report"
header_info["title"] = "Chaos Engineering Report" or title
header_info["today"] = datetime.now().strftime("%d %B %Y")
header_info["export_format"] = export_format
tags = []
Expand Down
7 changes: 6 additions & 1 deletion chaosreport/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def validate_vars(


@click.command()
@click.option(
"--title",
help="Title to use in the header of the report",
)
@click.option(
"--export-format",
default="markdown",
Expand Down Expand Up @@ -63,11 +67,12 @@ def report(
var_file: List[str] = None,
journal: str = "journal.json",
report: str = "report.md",
title: str = None,
):
"""
Generate a report from the run journal(s).
"""
header = generate_report_header(journal, export_format)
header = generate_report_header(journal, export_format, title)
report_path = report
reports = []

Expand Down

0 comments on commit b0b8cec

Please sign in to comment.