From 53f6c419171f04d63dc74c2112068330c4e54ac9 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Mon, 22 Jun 2020 17:40:35 +0200 Subject: [PATCH] osbuild: use osbuild_cli directly as main entry Instead of having a another indirection via `main_cli`, directly use `osbuild_cli` in as main function in `__main__.py`. Also use that in as the entry point for the generated `osbuild` executable. Change `osbuild_cli` to be self-contained, i.e. it directly uses `sys.argv` and `sys.exit`. --- osbuild/__main__.py | 5 ++--- osbuild/main_cli.py | 16 +++------------- setup.py | 2 +- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/osbuild/__main__.py b/osbuild/__main__.py index d374c67b..7d0c70f4 100755 --- a/osbuild/__main__.py +++ b/osbuild/__main__.py @@ -4,10 +4,9 @@ This specifies the entrypoint of the osbuild module when run as executable. For compatibility we will continue to run the CLI. """ -import sys -from osbuild.main_cli import main_cli as main +from osbuild.main_cli import osbuild_cli as main if __name__ == "__main__": - sys.exit(main()) + main() diff --git a/osbuild/main_cli.py b/osbuild/main_cli.py index 9cfb298e..c29d93a8 100644 --- a/osbuild/main_cli.py +++ b/osbuild/main_cli.py @@ -101,8 +101,8 @@ def parse_arguments(sys_argv): # pylint: disable=too-many-branches -def osbuild_cli(*, sys_argv): - args = parse_arguments(sys_argv) +def osbuild_cli(): + args = parse_arguments(sys.argv) manifest = parse_manifest(args.manifest_path) # first thing after parsing is validation of the input @@ -164,14 +164,4 @@ def osbuild_cli(*, sys_argv): print() print(f"{RESET}{BOLD}{RED}Failed{RESET}") - return 0 if r["success"] else 1 - - -def main_cli(): - """osbuild-cli entrypoint - - This is the entrypoint used by the `osbuild` executable. We simply fetch the - global configuration and parameters necessary and invoke the API entrypoint. - """ - - sys.exit(osbuild_cli(sys_argv=sys.argv)) + sys.exit(0 if r["success"] else 1) diff --git a/setup.py b/setup.py index 2132af85..0b7c7043 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setuptools.setup( ], entry_points={ "console_scripts": [ - "osbuild = osbuild.main_cli:main_cli" + "osbuild = osbuild.main_cli:osbuild_cli" ] }, )