Better output when parsing of arguments doesn't work

This commit is contained in:
Niklas Keller
2016-03-23 23:09:45 +01:00
parent 67e4fab090
commit 3e6be4abf1

View File

@@ -65,19 +65,21 @@ if (!in_array(PHP_SAPI, ["cli", "phpdbg"], true)) {
} }
if (count($argv) === 1 || in_array($argv[1], ["h", "-h", "help", "--help"], true)) { if (count($argv) === 1 || in_array($argv[1], ["h", "-h", "help", "--help"], true)) {
print $help; $climate->out($help);
exit(0); exit(0);
} }
if (!in_array($argv[1], $commands)) { if (!in_array($argv[1], $commands)) {
$climate->error("Unknown command '{$argv[1]}'. Use --help for a list of available commands."); $climate->br()->error(" Unknown command '{$argv[1]}'. Use --help for a list of available commands.");
$suggestion = \Kelunik\AcmeClient\suggestCommand($argv[1], $commands); $suggestion = \Kelunik\AcmeClient\suggestCommand($argv[1], $commands);
if ($suggestion) { if ($suggestion) {
$climate->br()->info(" Did you mean '$suggestion'?")->br(); $climate->br()->out(" Did you mean '$suggestion'?");
} }
$climate->br();
exit(1); exit(1);
} }