Skip to content

Commit

Permalink
feat: deprecated CLI command cyclonedx-bom prints deprecation warni…
Browse files Browse the repository at this point in the history
…ng on STDERR before execution (#489)

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
jkowalleck authored Feb 11, 2023
1 parent 4928515 commit 2009236
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion cyclonedx_py/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,22 @@ def _get_input_parser(self) -> BaseParser:
raise CycloneDxCmdException('Parser type could not be determined.')


def main(*, prog_name: Optional[str] = None) -> None:
def main(*, prog_name: Optional[str] = None, prog_name_instead: Optional[str] = None) -> None:
parser = CycloneDxCmd.get_arg_parser(prog=prog_name)
if prog_name_instead:
print('',
'!!! DEPRECATION WARNING !!!',
f'! The used call method "{parser.prog}" is deprecated.',
f'! Use "{prog_name_instead}" instead.',
'',
sep='\n', file=sys.stderr)
args = parser.parse_args()
CycloneDxCmd(args).execute()


def main_deprecated(*, prog_name: Optional[str] = None) -> None:
main(prog_name=prog_name, prog_name_instead='cyclonedx-py')


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ types-toml = "^0.10.8"
types-setuptools = ">= 57.0.0"

[tool.poetry.scripts]
cyclonedx-bom = 'cyclonedx_py.client:main' # deprecated as of https://github.com/CycloneDX/cyclonedx-python/issues/414
cyclonedx-bom = 'cyclonedx_py.client:main_deprecated' # deprecated as of https://github.com/CycloneDX/cyclonedx-python/issues/488
cyclonedx-py = 'cyclonedx_py.client:main'

[build-system]
Expand Down

0 comments on commit 2009236

Please sign in to comment.