Commit c80e08d3 authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

Améliore la sortie de la commande render.

No related merge requests found
Showing with 23 additions and 12 deletions
+23 -12
......@@ -14,6 +14,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\ProcessBuilder;
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
......@@ -48,35 +49,45 @@ class RenderCommand extends ContainerAwareCommand
$format = $input->getOption('format') ?: $this->getContainer()->getParameter('irstea_plant_uml.output.format');
$outputDir = $input->getOption('output') ?: $this->getContainer()->getParameter('irstea_plant_uml.output.directory');
$io = new SymfonyStyle($input, $output);
foreach($graphs as $name) {
$target = $outputDir . DIRECTORY_SEPARATOR . $name . "." . $format;
$output->writeln("Graphe: $name => $target.");
$io->section("Graphe: $name");
$graph = $this->getContainer()->get("irstea_plant_uml.graph.$name");
$this->renderGraph($graph, $target, $format, $output);
$this->renderGraph($graph, $target, $format, $io);
}
}
protected function renderGraph(Graph $graph, $target, $format, OutputInterface $output)
protected function renderGraph(Graph $graph, $target, $format, SymfonyStyle $io)
{
$output->write("Exploration des classes: ");
$io->writeln("Fichier de sortie: <comment>$target</comment>");
$io->write("Exploration des classes: ");
$graph->visitAll();
$output->writeln("Ok.");
$io->writeln("<info>Ok</info>.");
$output->write("Démarrage de PlantUML: ");
$io->write("Démarrage de PlantUML: ");
list($proc, $pipes) = $this->startProcess($target, $format);
$output->writeln("Ok.");
$io->writeln("<info>Ok</info>.");
$output->write("Génération du graphe: ");
$io->write("Génération du graphe: ");
$writer = new StreamWriter($pipes[0]);
$graph->writeTo($writer);
fclose($pipes[0]);
$output->writeln("Ok.");
$io->writeln("<info>Ok</info>.");
$output->write("Attente de PlantUML: ");
$io->write("Attente de PlantUML: ");
$res = proc_close($proc);
$output->writeln("Ok.");
dump($res);
if ($res === 0) {
$io->writeln("<info>Ok</info>.");
} else {
$io->writeln("<error>Nok</error>.");
}
}
protected function startProcess($target, $format)
......
Supports Markdown
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