/**
* @param InputInterface $input
* @param Container $services
* @return ITask
*/
public function create(InputInterface $input, Container $services)
{
if (!$input->getArgument('action')) {
throw new \InvalidArgumentException(sprintf('An action param is required: %s', json_encode(AliasCommand::$actions)));
}
if ($input->getArgument('action') === 'list') {
return new Listing($services);
}
if ($input->getArgument('action') === 'save') {
if (!$input->getArgument('name')) {
throw new \InvalidArgumentException('name param is mandatory for this action');
}
if (!$input->getArgument('bootstrap')) {
throw new \InvalidArgumentException('bootstrap param is mandatory for this action');
}
return new Saving($services);
}
if ($input->getArgument('action') === 'rm' || $input->getArgument('action') === 'remove') {
if (!$input->getArgument('name')) {
throw new \InvalidArgumentException('name param is mandatory for this action');
}
return new Removing($services);
}
$textFinder = new Finder($input->getArgument('action'), AliasCommand::$actions);
throw new \InvalidArgumentException(sprintf('Action "%s" not supported. Did you mean "%s"?', $input->getArgument('action'), $textFinder->first()));
}