Skip to content

Commit f99db57

Browse files
SCANPY-168 Limit size of output on wrong argument (#217)
1 parent 33f72bb commit f99db57

File tree

1 file changed

+9
-0
lines changed
  • src/pysonar_scanner/configuration

1 file changed

+9
-0
lines changed

src/pysonar_scanner/configuration/cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
from pysonar_scanner.exceptions import UnexpectedCliArgument
2525

2626

27+
class PyScannerHelpFormatter(argparse.HelpFormatter):
28+
recommended_args = {"help", "token", "sonar_project_key"}
29+
30+
def _format_actions_usage(self, actions, groups):
31+
filtered_actions = [action for action in actions if action.dest in PyScannerHelpFormatter.recommended_args]
32+
return super()._format_actions_usage(filtered_actions, groups)
33+
34+
2735
class CliConfigurationLoader:
2836

2937
@classmethod
@@ -59,6 +67,7 @@ def __create_parser(cls):
5967
parser = argparse.ArgumentParser(
6068
description="Sonar scanner CLI for Python",
6169
epilog="Analysis properties not listed here will also be accepted, as long as they start with the -D prefix.",
70+
formatter_class=PyScannerHelpFormatter,
6271
)
6372

6473
parser.add_argument(

0 commit comments

Comments
 (0)