1<?
php declare(strict_types=1);
11use Symfony\Component\Console\Command\Command;
12use Symfony\Component\Console\Input\InputInterface;
13use Symfony\Component\Console\Input\InputOption;
14use Symfony\Component\Console\Output\OutputInterface;
15use Symfony\Component\Console\Input\InputArgument;
52 $this->agent_finder = $agent_finder;
53 $this->config_reader = $config_reader;
60 $this->setDescription(
"Achieve a named objective from an agent.");
61 $this->addArgument(
"objective", InputArgument::REQUIRED,
"Objective to be execute from an agent. Format: \$AGENT::\$OBJECTIVE");
62 $this->addArgument(
"config", InputArgument::OPTIONAL,
"Configuration file for the installation");
63 $this->addOption(
"config",
null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
"Define fields in the configuration file that should be overwritten, e.g. \"a.b.c=foo\"", []);
64 $this->addOption(
"yes",
"y", InputOption::VALUE_NONE,
"Confirm every message of the update.");
67 public function execute(InputInterface $input, OutputInterface $output)
69 $objective_name = $input->getArgument(
'objective');
72 $io->printLicenseMessage();
73 $io->title(
"Achieve objective: $objective_name");
77 if ($input->getArgument(
"config")) {
83 $objective = $agent->getNamedObjective($objective_name,
$config);
85 if (count($this->preconditions) > 0) {
88 ...$this->preconditions
100 $this->achieveObjective($objective, $environment, $io);
101 $io->success(
"Achieved objective '$objective_name'. Thanks and have fun!");
103 $io->error(
"Aborted the attempt to achieve '$objective_name', a necessary confirmation is missing:\n\n" .
$e->getRequestedConfirmation());
110 if (!preg_match(
'/^\s*(\w+)::(\w+)\s*$/', $agent_method,
$result)) {
An exception for terminatinating execution or to throw for unit testing.
An agent that is just a collection of some other agents.
execute(InputInterface $input, OutputInterface $output)
$preconditions
var Objective[]
parseAgentMethod(string $agent_method)
__construct(AgentFinder $agent_finder, ConfigReader $config_reader, array $preconditions, Refinery $refinery)
Read a json-formatted config from a file and overwrite some fields.
Wrapper around symfonies input and output facilities to provide just the functionality required for t...
Signals that a necessary confirmation from the admin is missing.
A wrapper around an objective that adds some preconditions.
An environment holds resources to be used in the setup process.
const RESOURCE_ADMIN_INTERACTION
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addAgentConfigsToEnvironment(Agent $agent, Config $config, Environment $environment)
trait HasAgent
Add this to an Command that has an agent.
getRelevantAgent(InputInterface $input)
readAgentConfig(Agent $agent, InputInterface $input)
trait HasConfigReader
Add this to an Command that has an config reader.