From c80e08d39867767f9b68b820231c9409e2de4ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Perr=C3=A9al?= <guillaume.perreal@irstea.fr> Date: Thu, 12 May 2016 12:24:12 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9liore=20la=20sortie=20de=20la=20command?= =?UTF-8?q?e=20render.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Command/RenderCommand.php | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/Command/RenderCommand.php b/Command/RenderCommand.php index 3d8ac0b..387b169 100644 --- a/Command/RenderCommand.php +++ b/Command/RenderCommand.php @@ -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) -- GitLab