Skip to content

Commit

Permalink
Clean up helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 10, 2023
1 parent b6e5141 commit 78942a0
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions packages/framework/src/Console/Commands/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,21 @@ protected function getExecutablePath(): string

protected function runServerProcess(string $command): void
{
$outputHandler = $this->useBasicOutput() ? $this->getDefaultOutputHandler() : $this->getFancyOutputHandler();

Process::forever()->run($command, $outputHandler);
Process::forever()->run($command, $this->getOutputHandler());
}

protected function printStartMessage(): void
{
if ($this->useBasicOutput()) {
$this->line('<info>Starting the HydeRC server...</info> Press Ctrl+C to stop');
} else {
ConsoleOutput::printStartMessage($this->getHostSelection(), $this->getPortSelection());
}
$this->useBasicOutput()
? $this->line('<info>Starting the HydeRC server...</info> Press Ctrl+C to stop')
: ConsoleOutput::printStartMessage($this->getHostSelection(), $this->getPortSelection());
}

protected function getDefaultOutputHandler(): Closure
protected function getOutputHandler(): Closure
{
return function (string $type, string $line): void {
return $this->useBasicOutput() ? function (string $type, string $line): void {
$this->output->write($line);
};
}

protected function getFancyOutputHandler(): Closure
{
return ConsoleOutput::getFormatter($this->output->isVerbose());
} : ConsoleOutput::getFormatter($this->output->isVerbose());
}

protected function useBasicOutput(): bool
Expand Down

0 comments on commit 78942a0

Please sign in to comment.