Commit 80bc398b authored by Jon Pugh's avatar Jon Pugh

Make `provision save` automatically interactive for every property of every context!

parent 7b8ff8f8
......@@ -81,7 +81,14 @@ class SaveCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$context = $this->getApplication()->getContext($input->getArgument('context_name'));
try {
$context = $this->getApplication()->getContext($input->getArgument('context_name'));
}
catch (\Exception $e) {
$properties = $this->askForContextProperties();
$context = new ServerContext($input->getArgument('context_name'), $this->getApplication()->getConfig()->all(), $properties);
}
foreach ($context->getProperties() as $name => $value) {
$rows[] = [$name, $value];
}
......@@ -104,4 +111,19 @@ class SaveCommand extends Command
// $command = 'drush provision-save '.$input->getArgument('context_name');
// $this->process($command);
}
/**
* Loop through this context type's option_documentation() method and ask for each property.
*
* @return array
*/
private function askForContextProperties() {
$class = '\Aegir\Provision\Context\\' . ucfirst($this->input->getOption('context_type')) . "Context";
$options = $class::option_documentation();
$properties = [];
foreach ($options as $name => $description) {
$properties[$name] = $this->io->ask("$name ($description)");
}
return $properties;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment