Commit a1f3bd80 authored by Jon Pugh's avatar Jon Pugh

Add "context_name" argument to `provision status` to show information about a...

Add "context_name" argument to `provision status` to show information about a specific context. Add getContext() method to Aegir\Provision\Application
parent a10251f6
......@@ -139,4 +139,19 @@ class Application extends BaseApplication
}
return $contexts;
}
/**
* Load the Aegir context with the specified name.
*
* @param $name
*
* @return \Aegir\Provision\Context
* @throws \Exception
*/
function getContext($name) {
if (empty($this->getAllContexts()[$name])) {
throw new \Exception('Context not found with name: ' . $name);
}
return $this->getAllContexts()[$name];
}
}
......@@ -26,7 +26,15 @@ class StatusCommand extends Command
$this
->setName('status')
->setDescription('Display system status.')
->setHelp('Lists helpful information about your system.');
->setHelp('Lists helpful information about your system.')
->setDefinition([
new InputArgument(
'context_name',
InputArgument::OPTIONAL,
'Context to show info for.'
)
])
;
}
/**
......@@ -34,21 +42,34 @@ class StatusCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$io->comment('Provision Status');
$headers = ['Name', 'Value'];
$config = $this->getApplication()->getConfig()->all();
foreach ($config as $key => $value) {
$rows[] = [$key, $value];
if ($input->getArgument('context_name')) {
$context = $this->getApplication()->getContext($input->getArgument('context_name'));
$rows = [['Configuration File', $context->config_path]];
foreach ($context->getProperties() as $name => $value) {
$rows[] = [$name, $value];
}
$this->io->table(['Provision Context:', $input->getArgument('context_name')], $rows);
}
$io->table($headers, $rows);
// Lookup all contexts
$rows = [];
foreach ($this->getApplication()->getAllContexts() as $context) {
$rows[] = [$context->name, $context->type];
else {
$headers = ['Provision CLI Configuration'];
$rows = [['Configuration File', $this->getApplication()->getConfig()->getConfigPath()]];
$config = $this->getApplication()->getConfig()->all();
foreach ($config as $key => $value) {
$rows[] = [$key, $value];
}
$this->io->table($headers, $rows);
// Lookup all contexts
$rows = [];
foreach ($this->getApplication()->getAllContexts() as $context) {
$rows[] = [$context->name, $context->type];
}
$headers = ['Contexts'];
$this->io->table($headers, $rows);
$this->io->info('Use the command `provision status CONTEXT_NAME` to show more information about that context.');
}
$headers = ['Contexts'];
$io->table($headers, $rows);
}
}
......@@ -279,4 +279,11 @@ class Config implements ConfigurationInterface
return $home;
}
/**
* Determine the user running provision.
*/
public function getConfigPath() {
return $this->config_path;
}
}
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