Skip to content

Commit

Permalink
Rename the --sheet option to --model #1524
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed Jan 22, 2025
1 parent 91ea615 commit 3f15814
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
10 changes: 5 additions & 5 deletions docs/command-line-interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -396,15 +396,15 @@ your outputs on the host machine when running with Docker.

.. _cli_report:

`$ scanpipe report --sheet SHEET`
`$ scanpipe report --model MODEL`
---------------------------------

Generates an XLSX report of selected projects based on the provided criteria.

Required arguments:

- ``--sheet {package,dependency,resource,relation,message,todo}``
Specifies the sheet to include in the XLSX report. Available choices are based on
- ``--model {package,dependency,resource,relation,message,todo}``
Specifies the model to include in the XLSX report. Available choices are based on
predefined object types.

Optional arguments:
Expand All @@ -428,12 +428,12 @@ Example usage:
1. Generate a report for all projects tagged with "d2d" and include the **TODOS**
worksheet::

$ scanpipe report --sheet todo --label d2d
$ scanpipe report --model todo --label d2d

2. Generate a report for projects whose names contain the word "audit" and include the
**PACKAGES** worksheet::

$ scanpipe report --sheet package --search audit
$ scanpipe report --model package --search audit

.. _cli_check_compliance:

Expand Down
8 changes: 4 additions & 4 deletions scanpipe/management/commands/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def add_arguments(self, parser):
),
)
parser.add_argument(
"--sheet",
"--model",
required=True,
choices=list(output.object_type_to_model_name.keys()),
help="Specifies the sheet to include in the XLSX report.",
help="Specifies the model to include in the XLSX report.",
)
parser.add_argument(
"--search",
Expand All @@ -73,7 +73,7 @@ def handle(self, *args, **options):
output_directory = options["output_directory"]
labels = options["labels"]
search = options["search"]
sheet = options["sheet"]
model = options["model"]

if not (labels or search):
raise CommandError(
Expand All @@ -100,7 +100,7 @@ def handle(self, *args, **options):
else:
output_file = Path(filename)

output_file = output.get_xlsx_report(project_qs, sheet, output_file)
output_file = output.get_xlsx_report(project_qs, model, output_file)

run_time = timer() - start_time
if self.verbosity > 0:
Expand Down
1 change: 1 addition & 0 deletions scanpipe/tests/pipes/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def test_scanpipe_pipes_outputs_get_xlsx_report(self):

model_short_name = "todo"
output_file = output.get_xlsx_report(project_qs, model_short_name)
workbook = openpyxl.load_workbook(output_file, read_only=True, data_only=True)
expected_sheet_names = [
"TODOS",
]
Expand Down
8 changes: 4 additions & 4 deletions scanpipe/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,16 +1104,16 @@ def test_scanpipe_management_command_report(self):
make_resource_file(project1, path="file.ext", status=flag.REQUIRES_REVIEW)
make_project("project2")

expected = "Error: the following arguments are required: --sheet"
expected = "Error: the following arguments are required: --model"
with self.assertRaisesMessage(CommandError, expected):
call_command("report")

options = ["--sheet", "UNKNOWN"]
expected = "Error: argument --sheet: invalid choice: 'UNKNOWN'"
options = ["--model", "UNKNOWN"]
expected = "Error: argument --model: invalid choice: 'UNKNOWN'"
with self.assertRaisesMessage(CommandError, expected):
call_command("report", *options)

options = ["--sheet", "todo"]
options = ["--model", "todo"]
expected = "You must provide either --label or --search to select projects."
with self.assertRaisesMessage(CommandError, expected):
call_command("report", *options)
Expand Down

0 comments on commit 3f15814

Please sign in to comment.