131 : void
132 {
134 $objective_name = $input->getArgument('objective');
135
136 $io->title("Achieve objective: $objective_name");
137
138 $config = null;
139 if ($input->getArgument("config")) {
141 }
142
143 $namedObjectives = $agent->getNamedObjectives($config);
144
145 if (isset($namedObjectives[$objective_name])) {
146 $objective = $namedObjectives[$objective_name];
147 } else {
148 throw new InvalidArgumentException(
149 "There is no named objective '$objective_name'"
150 );
151 }
152
153 if ($this->preconditions !== []) {
154 $objective = new ObjectiveWithPreconditions(
155 $objective->create(),
156 ...$this->preconditions
157 );
158 } else {
159 $objective = $objective->create();
160 }
161
162 $environment = new ArrayEnvironment([
164 ]);
165 if ($config !== null) {
167 }
168
169 try {
170 $this->achieveObjective($objective, $environment, $io);
171 $io->success("Achieved objective '$objective_name'. Thanks and have fun!");
172 }
catch (NoConfirmationException
$e) {
173 $io->error(
"Aborted the attempt to achieve '$objective_name', a necessary confirmation is missing:\n\n" .
$e->getRequestedConfirmation());
174 }
175 }
const RESOURCE_ADMIN_INTERACTION
addAgentConfigsToEnvironment(Agent $agent, Config $config, Environment $environment)
getRelevantAgent(InputInterface $input)
readAgentConfig(Agent $agent, InputInterface $input, ?string $use_config_field=null)