setName('config-get')
->setDefinition([
new InputArgument('key', InputArgument::OPTIONAL, 'Runtime-configurable option to inspect.'),
])
->setDescription('Print the current value for one runtime-configurable PsySH setting.');
}
public function asText(): string
{
return \implode("\n", [
'Usage:',
' config get \\',
'',
'Help:',
' Print the current value for one runtime-configurable PsySH setting.',
'',
'Examples:',
' >>> config get verbosity',
' >>> config get theme',
'',
'Supported Options:',
' '.$this->formatOptionNames($this->getOptionNames()),
]);
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$key = $input->getArgument('key');
if ($key === null) {
throw new \InvalidArgumentException('Please specify a runtime-configurable option to inspect.');
}
$option = $this->getOption($key);
if ($option === null) {
$output->writeln(\sprintf('%s', $this->unsupportedMessage((string) $key)));
return 1;
}
$output->writeln($this->formatValue($option['getter']()));
return 0;
}
}