Skip to content

Commit

Permalink
refactor(app): output helper instantiation and print trace
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Aug 21, 2018
1 parent 1783561 commit 7b5080e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,7 @@ public function handle(array $argv)
$this->doAction($command);
$exitCode = 0;
} catch (\Throwable $e) {
$this->io()->error($e->getMessage(), true);

if (!$e instanceof Exception) {
$location = \get_class($e) . ' thrown in ' . $e->getFile() . ' on line ' . $e->getLine();
$this->io()->bgRed($location, true);
}
$this->outputHelper()->printTrace($e);
}

return ($this->onExit)($exitCode);
Expand Down Expand Up @@ -311,20 +306,25 @@ protected function aliasesFor(Command $command): array
public function showHelp()
{
$writer = $this->io()->writer();
$helper = new OutputHelper($writer);

$header = "{$this->name}, version {$this->version}";
$footer = 'Run `<command> --help` for specific help';

if ($this->logo) {
$writer->write($this->logo, true);
}

$helper->showCommandsHelp($this->commands(), $header, $footer);
$this->outputHelper()->showCommandsHelp($this->commands(), $header, $footer);

return ($this->onExit)();
}

protected function outputHelper(): OutputHelper
{
$writer = $this->io()->writer();

return new OutputHelper($writer);
}

/**
* Invoke command action.
*
Expand Down

0 comments on commit 7b5080e

Please sign in to comment.