Skip to content

Commit

Permalink
KOJO-167,169,175 | Update Symfony\Console command contracts to match …
Browse files Browse the repository at this point in the history
…4.4 changes
  • Loading branch information
mucha55 committed Jan 7, 2020
1 parent 42b2963 commit 0db8cfc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/Console/Command/Db/Setup/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ protected function _configure(): CommandAbstract
return $this;
}

public function _execute(): CommandAbstract
public function _execute(): int
{
$this->_getDbSetup()->install();
$this->_getOutput()->writeln('Kōjō has been successfully installed!');

return $this;
return 0;
}

protected function _getHelp(): string
Expand All @@ -36,4 +36,4 @@ protected function _getHelp(): string
The client's Bootstrap class will be called prior to setup, and that \PDO class will be used for setup.
EOD;
}
}
}
10 changes: 5 additions & 5 deletions src/Console/Command/Db/TearDown/Uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ protected function _configure(): CommandAbstract
return $this;
}

public function _execute(): CommandAbstract
public function _execute(): int
{
if ($this->_isUninstallConfirmedByUser()) {
$this->_getDbTearDown()->uninstall();
$this->_getOutput()->writeln('Kōjō has been successfully uninstalled.');
} else {
$this->_getOutput()->writeln('Kōjō was not uninstalled.');
return 0;
}

return $this;
$this->_getOutput()->writeln('Kōjō was not uninstalled.');
return 255;
}

protected function _isUninstallConfirmedByUser(): bool
Expand Down Expand Up @@ -96,4 +96,4 @@ protected function _getHelp(): string
The client's Bootstrap class will be called prior to setup, and that \PDO class will be used for setup.
EOD;
}
}
}
8 changes: 5 additions & 3 deletions src/Console/Command/Process/Pool/Server/Start.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function _configure(): CommandAbstract
return $this;
}

public function _execute(): CommandAbstract
public function _execute(): int
{
$arguments = [self::OPT_RUN_SERVER];
$arguments[] = self::OPT_YSDP . $this->_getInput()->getArgument(self::ARG_SERVICES_YML_ROOT_DIRECTORY_PATH);
Expand All @@ -40,7 +40,9 @@ public function _execute(): CommandAbstract
pcntl_exec(__DIR__ . '/../../../../../../bin/kojo', $arguments);
$this->_getOutput()->writeln('An error occurred trying to start the process pool server.');

return $this;
// currently there is no graceful shutdown flow for kojo, it works until terminated
// if, in the future, we want such a flow, and want to expose its success via exit code, we will need to make changes here
return 255;
}

protected function _getHelp()
Expand All @@ -51,4 +53,4 @@ protected function _getHelp()
The default number of servers started is one.
EOD;
}
}
}
8 changes: 3 additions & 5 deletions src/Console/CommandAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ public function execute(InputInterface $input, OutputInterface $output)
if ($this->_getInput()->getOption(self::OPT_ENABLE_SPLASH_ART)) {
$this->_writeSplashArt();
}
$this->_execute();

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

protected function _setOutput(OutputInterface $output): CommandAbstract
Expand All @@ -84,12 +82,12 @@ protected function _getInput(): InputInterface
return $this->_read(InputInterface::class);
}

abstract function _execute(): CommandAbstract;
abstract function _execute(): int;

protected function _writeSplashArt(): CommandAbstract
{
$this->_getOutput()->writeln(self::SPLASH_ART);

return $this;
}
}
}

0 comments on commit 0db8cfc

Please sign in to comment.