From fb0509ae7e3c06d7c1a63539b0458cc541d8fb95 Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Mon, 28 Mar 2016 12:27:02 +0200 Subject: [PATCH] Show help when --help is included, not only if parsing fails and then --help is included --- bin/acme | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/acme b/bin/acme index 6c2c61f..bda0076 100755 --- a/bin/acme +++ b/bin/acme @@ -105,22 +105,23 @@ try { unset($args[1]); $climate->arguments->add($definition); - $climate->arguments->parse(array_values($args)); -} catch (Exception $e) { + if (count($argv) === 3 && in_array($argv[2], ["h", "-h", "--help", "help"], true)) { $climate->usage(["{$binary} {$argv[1]}"]); $climate->br(); exit(0); } else { - $climate->usage(["{$binary} {$argv[1]}"]); - $climate->br(); - - $climate->error($e->getMessage()); - $climate->br(); - - exit(1); + $climate->arguments->parse(array_values($args)); } +} catch (Exception $e) { + $climate->usage(["{$binary} {$argv[1]}"]); + $climate->br(); + + $climate->error($e->getMessage()); + $climate->br(); + + exit(1); } $injector = new Injector;