Skip to content

Commit

Permalink
Simplified beeping-on-error implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 committed Aug 20, 2024
1 parent 1764e11 commit 1efcca2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 30 deletions.
18 changes: 18 additions & 0 deletions src/SVNBuddy/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
use ConsoleHelpers\ConsoleKit\Container as BaseContainer;
use ConsoleHelpers\SVNBuddy\Command\AggregateCommand;
use ConsoleHelpers\SVNBuddy\Repository\Connector\Connector;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\CommandLoader\CommandLoaderInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class Application extends BaseApplication
{
Expand Down Expand Up @@ -44,6 +47,21 @@ public function __construct(BaseContainer $container)
putenv('LC_CTYPE=en_US.UTF-8'); // For SVN.
}

/**
* @inheritDoc
*/
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
{
try {
return parent::doRunCommand($command, $input, $output);
}
catch ( \Exception $e ) {
$this->dic['io']->notify();

throw $e;
}
}

/**
* Returns the long version of the application.
*
Expand Down
30 changes: 0 additions & 30 deletions src/SVNBuddy/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@
abstract class AbstractCommand extends BaseCommand
{

/**
* Command depth.
*
* @var integer
*/
private static $_commandDepth = 0;

/**
* Raw path.
*
Expand Down Expand Up @@ -178,29 +171,6 @@ protected function prepareDependencies()
$this->_updateManager = $container['update_manager'];
}

/**
* @inheritDoc
*
* @throws CommandException When command exception is caught.
*/
public function run(InputInterface $input, OutputInterface $output)
{
self::$_commandDepth++;

try {
return parent::run($input, $output);
}
catch ( CommandException $e ) {
if ( self::$_commandDepth === 1 ) {
$this->io->notify();
}

throw $e;
} finally {
self::$_commandDepth--;
}
}

/**
* Returns command setting value.
*
Expand Down

0 comments on commit 1efcca2

Please sign in to comment.