diff --git a/scripts/ssh/ssh-exec.php b/scripts/ssh/ssh-exec.php index eea2db4712..387eb9d0d2 100755 --- a/scripts/ssh/ssh-exec.php +++ b/scripts/ssh/ssh-exec.php @@ -211,21 +211,29 @@ try { ->setUniqueMethod('getName') ->execute(); + $command_list = array_keys($workflows); + $command_list = implode(', ', $command_list); + + $error_lines = array(); + $error_lines[] = pht('Welcome to Phabricator.'); + $error_lines[] = pht( + 'You are logged in as %s.', + $user_name); + if (!$original_argv) { - throw new Exception( - pht( - "Welcome to Phabricator.\n\n". - "You are logged in as %s.\n\n". - "You haven't specified a command to run. This means you're requesting ". - "an interactive shell, but Phabricator does not provide an ". - "interactive shell over SSH.\n\n". - "Usually, you should run a command like `%s` or `%s` ". - "rather than connecting directly with SSH.\n\n". - "Supported commands are: %s.", - $user_name, - 'git clone', - 'hg push', - implode(', ', array_keys($workflows)))); + $error_lines[] = pht( + 'You have not specified a command to run. This means you are requesting '. + 'an interactive shell, but Phabricator does not provide interactive '. + 'shells over SSH.'); + $error_lines[] = pht( + '(Usually, you should run a command like "git clone" or "hg push" '. + 'instead of connecting directly with SSH.)'); + $error_lines[] = pht( + 'Supported commands are: %s.', + $command_list); + + $error_lines = implode("\n\n", $error_lines); + throw new PhutilArgumentUsageException($error_lines); } $log_argv = implode(' ', $original_argv); @@ -247,7 +255,20 @@ try { $parsed_args = new PhutilArgumentParser($parseable_argv); if (empty($workflows[$command])) { - throw new Exception(pht('Invalid command.')); + $error_lines[] = pht( + 'You have specified the command "%s", but that command is not '. + 'supported by Phabricator. As received by Phabricator, your entire '. + 'argument list was:', + $command); + + $error_lines[] = csprintf(' $ ssh ... -- %Ls', $parseable_argv); + + $error_lines[] = pht( + 'Supported commands are: %s.', + $command_list); + + $error_lines = implode("\n\n", $error_lines); + throw new PhutilArgumentUsageException($error_lines); } $workflow = $parsed_args->parseWorkflows($workflows);