This is an automated email from the ASF dual-hosted git repository. klueska pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
The following commit(s) were added to refs/heads/master by this push: new 992e3c4 Updated new CLI to propagate commands exit status properly. 992e3c4 is described below commit 992e3c4efd2f607b60f5e4b5bea7999692a01c0a Author: Armand Grillet <agril...@mesosphere.io> AuthorDate: Fri Nov 2 19:42:59 2018 -0400 Updated new CLI to propagate commands exit status properly. In a later commit, this will be used by the two subcommands 'task attach' and 'task exec' to return their proper exit statuses. Review: https://reviews.apache.org/r/69206/ --- src/python/cli_new/bin/main.py | 18 +++++++++--------- src/python/cli_new/lib/cli/plugins/base.py | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/python/cli_new/bin/main.py b/src/python/cli_new/bin/main.py index 27783ca..430add4 100644 --- a/src/python/cli_new/bin/main.py +++ b/src/python/cli_new/bin/main.py @@ -124,31 +124,31 @@ def main(argv): print(option) print(" ".join(comp_words)) + return 0 # Use the meta-command "help" to print help information for the # supplied command and its subcommands. - elif cmd == "help": + if cmd == "help": if argv and argv[0] in cmds: plugin = cli.util.get_module(plugins, argv[0]) plugin_class = getattr(plugin, plugin.PLUGIN_CLASS) - plugin_class(settings, config).main(argv[1:] + ["--help"]) - else: - main(["--help"]) + return plugin_class(settings, config).main(argv[1:] + ["--help"]) + + return main(["--help"]) # Run the command through its plugin. - elif cmd in list(cmds.keys()): + if cmd in list(cmds.keys()): plugin = cli.util.get_module(plugins, cmd) plugin_class = getattr(plugin, plugin.PLUGIN_CLASS) - plugin_class(settings, config).main(argv) + return plugin_class(settings, config).main(argv) # Print help information if no commands match. - else: - main(["--help"]) + return main(["--help"]) if __name__ == "__main__": try: - main(sys.argv[1:]) + sys.exit(main(sys.argv[1:])) except CLIException as exception: sys.exit("Error: {error}.".format(error=str(exception))) except KeyboardInterrupt: diff --git a/src/python/cli_new/lib/cli/plugins/base.py b/src/python/cli_new/lib/cli/plugins/base.py index c85abd6..e0fcbbf 100644 --- a/src/python/cli_new/lib/cli/plugins/base.py +++ b/src/python/cli_new/lib/cli/plugins/base.py @@ -175,6 +175,6 @@ class PluginBase(): cmd = self.COMMANDS[cmd]["alias"] self.__setup__(cmd, argv) - getattr(self, cmd.replace("-", "_"))(arguments) - else: - self.main(["--help"]) + return getattr(self, cmd.replace("-", "_"))(arguments) + + return self.main(["--help"])