Lines
100.00%
28 / 28
Methods
100.00%
12 / 12
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| sendAppRequest | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Runtime\Console\AppRequestCommand] __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Runtime\Console\AppRequestCommand] configure | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Runtime\Console\AppRequestCommand] execute | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 2 | ||
| [Stewart\Runtime\Console\ControlCommand] resolveControlTarget | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Runtime\Console\ControlCommand] writeCommandResult | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 2 | ||
| [Stewart\Runtime\Console\ControlCommand] parseTimeoutOption | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Runtime\Console\StewartCommand] findConfigOption | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Runtime\Console\StewartCommand] nonEmptyStringOption | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 3 | ||
| [Stewart\Runtime\Console\StewartCommand] writeMissingConfigFileNotice | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 2 | ||
| [Stewart\Runtime\Console\StewartCommand] writeNotice | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | ||
| [Stewart\Runtime\Console\StewartCommand] readStringArgument | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 2 | ||
| 14 | final class AppResumeCommand extends AppRequestCommand | |
| 15 | { | |
| 16 | public const string NAME = 'app:resume'; | |
| 17 | ||
| 18 | protected function sendAppRequest(ControlTarget $target, AppId $appId, Duration $timeout): CommandResult | |
| 19 | { | |
| 20 | return $this->client->resumeApp($target, $appId, $timeout); | |
| 21 | } | |
| 22 | } |
Inherited from Stewart\Runtime\Console\AppRequestCommand
| 25 | public function __construct( | |
| 26 | ConfigLoader $config, | |
| 27 | ControlTargetResolver $targets, | |
| 28 | protected readonly ControlClient $client, | |
| 29 | ) { | |
| 30 | parent::__construct($config, $targets); | |
| 31 | } |
| 33 | protected function configure(): void | |
| 34 | { | |
| 35 | parent::configure(); | |
| 36 | $this->addArgument('app', InputArgument::REQUIRED, 'The automation ID, as shown by stewart status'); | |
| 37 | } |
| 39 | protected function execute(InputInterface $input, OutputInterface $output): int | |
| 40 | { | |
| 41 | try { | |
| 42 | $result = $this->sendAppRequest($this->resolveControlTarget($input), new AppId($this->readStringArgument($input, 'app')), $this->parseTimeoutOption($input)); | |
| 43 | } catch (StewartException|StreamException|CancelledException $e) { | |
| 44 | $output->writeln('<error>' . $e->getMessage() . '</error>'); | |
| 45 | ||
| 46 | return Command::FAILURE; | |
| 47 | } | |
| 48 | ||
| 49 | $this->writeCommandResult($output, $result); | |
| 50 | ||
| 51 | return Command::SUCCESS; | |
| 52 | } |
Inherited from Stewart\Runtime\Console\ControlCommand
| 39 | protected function resolveControlTarget(InputInterface $input): ControlTarget | |
| 40 | { | |
| 41 | $path = $this->findConfigOption($input); | |
| 42 | ||
| 43 | return $this->targets->resolveTarget( | |
| 44 | $this->nonEmptyStringOption($input, 'address'), | |
| 45 | $this->nonEmptyStringOption($input, 'token'), | |
| 46 | fn(): ControlConfig => $this->config->loadConfig($path)->control, | |
| 47 | ); | |
| 48 | } |
| 50 | protected function writeCommandResult(OutputInterface $output, CommandResult $result): void | |
| 51 | { | |
| 52 | $output->writeln($result->message); | |
| 53 | ||
| 54 | if ($result->warning !== null) { | |
| 55 | $this->writeNotice($output, $result->warning); | |
| 56 | } | |
| 57 | } |
| 60 | protected function parseTimeoutOption(InputInterface $input): Duration | |
| 61 | { | |
| 62 | return Duration::parse($this->nonEmptyStringOption($input, 'timeout') ?? self::DEFAULT_TIMEOUT); | |
| 63 | } |
Inherited from Stewart\Runtime\Console\StewartCommand
| 20 | protected function findConfigOption(InputInterface $input): ?string | |
| 21 | { | |
| 22 | return $this->nonEmptyStringOption($input, 'config'); | |
| 23 | } |
| 25 | protected function nonEmptyStringOption(InputInterface $input, string $name): ?string | |
| 26 | { | |
| 27 | $value = $input->getOption($name); | |
| 28 | ||
| 29 | return \is_string($value) && $value !== '' ? $value : null; | |
| 30 | } |
| 32 | protected function writeMissingConfigFileNotice(OutputInterface $output, ?string $missingConfigFile): void | |
| 33 | { | |
| 34 | if ($missingConfigFile !== null) { | |
| 35 | $this->writeNotice($output, \sprintf('No config file at %s; using the environment only.', $missingConfigFile)); | |
| 36 | } | |
| 37 | } |
| 39 | protected function writeNotice(OutputInterface $output, string $notice): void | |
| 40 | { | |
| 41 | ($output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output)->writeln('<comment>' . $notice . '</comment>'); | |
| 42 | } |
| 44 | protected function readStringArgument(InputInterface $input, string $name): string | |
| 45 | { | |
| 46 | $value = $input->getArgument($name); | |
| 47 | ||
| 48 | return \is_string($value) ? $value : ''; | |
| 49 | } |