From ee03c2159d1cfe45b61a661a42fd09d22ceac3cc Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Sat, 5 Apr 2025 14:31:06 +0200 Subject: [PATCH] refactor: reorder CLI switches Signed-off-by: Jan Kowalleck --- cyclonedx_py/_internal/cli.py | 48 +++++++++++++------------- docs/usage.rst | 64 +++++++++++++++++------------------ 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/cyclonedx_py/_internal/cli.py b/cyclonedx_py/_internal/cli.py index 135a65b1..8a6108f5 100644 --- a/cyclonedx_py/_internal/cli.py +++ b/cyclonedx_py/_internal/cli.py @@ -76,20 +76,6 @@ def make_argument_parser(cls, sco: ArgumentParser, **kwargs: Any) -> ArgumentPar action='store_true', dest='short_purls', default=False) - op.add_argument('--outfile', # DEPRECATED - metavar='', - help='DEPRECATED alias for "--output-file".', - type=FileType('wt', encoding='utf8'), - dest='output_file', - default=OPTION_OUTPUT_STDOUT) - op.add_argument('-o', '--output-file', - metavar='', - help='Output file path for your SBOM' - f' (set to "{OPTION_OUTPUT_STDOUT}" to output to )' - ' (default: %(default)s)', - type=FileType('wt', encoding='utf8'), - dest='output_file', - default=OPTION_OUTPUT_STDOUT) op.add_argument('--schema-version', # DEPRECATED metavar='', help='DEPRECATED alias for option "--spec-version".', @@ -100,27 +86,41 @@ def make_argument_parser(cls, sco: ArgumentParser, **kwargs: Any) -> ArgumentPar op.add_argument('--sv', '--spec-version', metavar='', help='The CycloneDX spec version for your SBOM' - f' {{choices: {", ".join(sorted((v.to_version() for v in SchemaVersion), reverse=True))}}}' - ' (default: %(default)s)', + f' {{choices: {", ".join(sorted((v.to_version() for v in SchemaVersion), reverse=True))}}}' + ' (default: %(default)s)', dest='spec_version', choices=SchemaVersion, type=SchemaVersion.from_version, default=SchemaVersion.V1_5.to_version()) + op.add_argument('--output-reproducible', + help='Whether to go the extra mile and make the output reproducible.\n' + 'This might result in loss of time- and random-based-values.', + action='store_true', + dest='output_reproducible', + default=False) op.add_argument('--of', '--output-format', metavar='', help='The output format for your SBOM' - f' {choices4enum(OutputFormat)}' - ' (default: %(default)s)', + f' {choices4enum(OutputFormat)}' + ' (default: %(default)s)', dest='output_format', choices=OutputFormat, type=argparse_type4enum(OutputFormat), default=OutputFormat.JSON.name) - op.add_argument('--output-reproducible', - help='Whether to go the extra mile and make the output reproducible.\n' - 'This might result in loss of time- and random-based-values.', - action='store_true', - dest='output_reproducible', - default=False) + op.add_argument('--outfile', # DEPRECATED + metavar='', + help='DEPRECATED alias for "--output-file".', + type=FileType('wt', encoding='utf8'), + dest='output_file', + default=OPTION_OUTPUT_STDOUT) + op.add_argument('-o', '--output-file', + metavar='', + help='Output file path for your SBOM' + f' (set to "{OPTION_OUTPUT_STDOUT}" to output to )' + ' (default: %(default)s)', + type=FileType('wt', encoding='utf8'), + dest='output_file', + default=OPTION_OUTPUT_STDOUT) if BooleanOptionalAction: op.add_argument('--validate', help='Whether validate the result before outputting' diff --git a/docs/usage.rst b/docs/usage.rst index a250646b..66fb140a 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -81,24 +81,24 @@ The full documentation can be issued by running with ``environment --help``: (default: application) --short-PURLs Omit all qualifiers from PackageURLs. This causes information loss in trade-off shorter PURLs, which might improve ingesting these strings. - --outfile DEPRECATED alias for "--output-file". - -o , --output-file - Output file path for your SBOM - (set to "-" to output to STDOUT) - (default: -) --schema-version DEPRECATED alias for "--spec-version" --sv , --spec-version The CycloneDX schema version for your SBOM {choices: 1.6, 1.5, 1.4, 1.3, 1.2, 1.1, 1.0} (default: 1.5) + --output-reproducible + Whether to go the extra mile and make the output reproducible. + This might result in loss of time- and random-based-values. --of , --output-format The output format for your SBOM {choices: JSON, XML} (default: JSON) - --output-reproducible - Whether to go the extra mile and make the output reproducible. - This might result in loss of time- and random-based-values. + --outfile DEPRECATED alias for "--output-file". + -o , --output-file + Output file path for your SBOM + (set to "-" to output to STDOUT) + (default: -) --validate, --no-validate Whether validate the result before outputting (default: True) @@ -255,24 +255,24 @@ The full documentation can be issued by running with ``pipenv --help``: (default: application) --short-PURLs Omit all qualifiers from PackageURLs. This causes information loss in trade-off shorter PURLs, which might improve ingesting these strings. - --outfile DEPRECATED alias for "--output-file". - -o , --output-file - Output file path for your SBOM - (set to "-" to output to ) - (default: -) --schema-version DEPRECATED alias for "--spec-version" --sv , --spec-version The CycloneDX schema version for your SBOM {choices: 1.6, 1.5, 1.4, 1.3, 1.2, 1.1, 1.0} (default: 1.5) + --output-reproducible + Whether to go the extra mile and make the output reproducible. + This might result in loss of time- and random-based-values. --of , --output-format The output format for your SBOM {choices: JSON, XML} (default: JSON) - --output-reproducible - Whether to go the extra mile and make the output reproducible. - This might result in loss of time- and random-based-values. + --outfile DEPRECATED alias for "--output-file". + -o , --output-file + Output file path for your SBOM + (set to "-" to output to STDOUT) + (default: -) --validate, --no-validate Whether validate the result before outputting (default: True) @@ -333,24 +333,24 @@ The full documentation can be issued by running with ``poetry --help``: (default: application) --short-PURLs Omit all qualifiers from PackageURLs. This causes information loss in trade-off shorter PURLs, which might improve ingesting these strings. - --outfile DEPRECATED alias for "--output-file". - -o , --output-file - Output file path for your SBOM - (set to "-" to output to ) - (default: -) --schema-version DEPRECATED alias for "--spec-version" --sv , --spec-version The CycloneDX schema version for your SBOM {choices: 1.6, 1.5, 1.4, 1.3, 1.2, 1.1, 1.0} (default: 1.5) + --output-reproducible + Whether to go the extra mile and make the output reproducible. + This might result in loss of time- and random-based-values. --of , --output-format The output format for your SBOM {choices: JSON, XML} (default: JSON) - --output-reproducible - Whether to go the extra mile and make the output reproducible. - This might result in loss of time- and random-based-values. + --outfile DEPRECATED alias for "--output-file". + -o , --output-file + Output file path for your SBOM + (set to "-" to output to STDOUT) + (default: -) --validate, --no-validate Whether validate the result before outputting (default: True) @@ -407,24 +407,24 @@ The full documentation can be issued by running with ``requirements --help``: (default: application) --short-PURLs Omit all qualifiers from PackageURLs. This causes information loss in trade-off shorter PURLs, which might improve ingesting these strings. - --outfile DEPRECATED alias for "--output-file". - -o , --output-file - Output file path for your SBOM - (set to "-" to output to ) - (default: -) --schema-version DEPRECATED alias for "--spec-version" --sv , --spec-version The CycloneDX schema version for your SBOM {choices: 1.6, 1.5, 1.4, 1.3, 1.2, 1.1, 1.0} (default: 1.5) + --output-reproducible + Whether to go the extra mile and make the output reproducible. + This might result in loss of time- and random-based-values. --of , --output-format The output format for your SBOM {choices: JSON, XML} (default: JSON) - --output-reproducible - Whether to go the extra mile and make the output reproducible. - This might result in loss of time- and random-based-values. + --outfile DEPRECATED alias for "--output-file". + -o , --output-file + Output file path for your SBOM + (set to "-" to output to STDOUT) + (default: -) --validate, --no-validate Whether validate the result before outputting (default: True)