Commit e0a58ece authored by Jon Pugh's avatar Jon Pugh

If the context_name argument was not specified, ask for which one the user wanted.

parent a9cb701a
......@@ -174,6 +174,17 @@ class Application extends BaseApplication
}
}
/**
* Get a simple array of all contexts, for use in an options list.
* @return array
*/
public function getAllContextsOptions() {
foreach ($this->getAllContexts() as $name => $context) {
$options[$name] = $context->type . ' ' . $context->name;
}
return $options;
}
/**
* Load the Aegir context with the specified name.
*
......
......@@ -85,8 +85,22 @@ abstract class Command extends BaseCommand
}
}
}
// If context_name is not specified, ask for it.
elseif ($this->getDefinition()->getArgument('context_name')->isRequired()) {
$this->askForContext();
$this->input->setArgument('context_name', $this->context_name);
$this->context = $this->getApplication()->getContext($this->context_name);
}
}
/**
* Show a list of Contexts to the user for them to choose from.
*/
public function askForContext($question = 'Choose a context') {
$this->context_name = $this->io->choice($question, $this->getApplication()->getAllContextsOptions());
}
/**
* Run a process.
*
......
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