From 49e77da47fc4519c337759957b7f2d011b3cc958 Mon Sep 17 00:00:00 2001 From: Steven Troxler Date: Tue, 19 Apr 2022 20:12:31 -0700 Subject: [PATCH] Use a callback in the `pyre servers` command Reviewed By: shannonzhu Differential Revision: D35766678 fbshipit-source-id: 989d567bcd4d61db4e6e5bf5b7b09df9bc1b5270 --- client/pyre.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/client/pyre.py b/client/pyre.py index 2c934ca1416..4e9aa4f9e26 100755 --- a/client/pyre.py +++ b/client/pyre.py @@ -922,15 +922,30 @@ def restart( invoke_without_command=True, ) @click.pass_context -def servers(context: click.Context) -> int: +def servers(context: click.Context) -> None: """ Commands to manipulate multiple Pyre servers. """ + pass + + +@servers.result_callback() +@click.pass_context +def run_default_servers_command( + context: click.Context, + value: Optional[commands.ExitCode], + *args: object, + **kwargs: object, +) -> commands.ExitCode: if context.invoked_subcommand is None: arguments: command_arguments.CommandArguments = context.obj["arguments"] return commands.servers.run_list(arguments.output) - # This return value is not used anywhere. - return commands.ExitCode.SUCCESS + elif value is not None: + return value + else: + raise commands.ClientException( + "Non-default serevers subcommand did not return a value" + ) @servers.command(name="list")