blob: 9444dc954a1c28ae18366fb107c5731289e24505 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?php
namespace Studip\Cli\Commands\Config;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\Table;
class SetConfigValue extends Command
{
protected static $defaultName = 'config:set';
protected function configure(): void
{
$this->setDescription('Set value of a Stud.IP configuration key.');
$this->setHelp('This command will set the value of a Stud.IP configuration key.');
$this->addArgument('config-key', InputArgument::REQUIRED, 'Key of the configuration.');
$this->addArgument('config-value', InputArgument::REQUIRED, 'Value of the configuration.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$configKey = $input->getArgument('config-key');
$configValue = $input->getArgument('config-value');
$metadata = \Config::get()->getMetadata($configKey);
if (!$metadata) {
throw new \RuntimeException("Unknown config key '{$configKey}");
}
\Config::get()->store($configKey, $configValue);
return Command::SUCCESS;
}
}
|