Skip to content

Commit

Permalink
minor #64 Handle no-ansi outputs (tgalopin)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.4.x-dev branch.

Discussion
----------

Handle no-ansi outputs

Commits
-------

5811f41 Handle no-ansi outputs
  • Loading branch information
lyrixx committed May 30, 2017
2 parents a6e7ef5 + 5811f41 commit d6b0edb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Cli/Command/AnalyzeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,25 @@ protected function execute(InputInterface $input, OutputInterface $output)
$analysis = $api->analyze($projectUuid, $input->getOption('reference'));

$chars = array('-', '\\', '|', '/');
$noAnsiStatus = 'Analysis queued';
$output->writeln($noAnsiStatus);

$position = 0;

while (true) {
// we don't check the status too often
if (0 == $position % 2) {
if (0 === $position % 2) {
$analysis = $api->getAnalysisStatus($projectUuid, $analysis->getNumber());
}

if ('txt' === $input->getOption('format')) {
$output->write(sprintf("%s %-80s\r", $chars[$position % 4], $analysis->getStatusMessage()));
if ($input->getOption('no-ansi')) {
if ($noAnsiStatus !== $analysis->getStatusMessage()) {
$output->writeln($noAnsiStatus = $analysis->getStatusMessage());
}
} else {
$output->write(sprintf("%s %-80s\r", $chars[$position % 4], $analysis->getStatusMessage()));
}
}

if ($analysis->isFinished()) {
Expand Down

0 comments on commit d6b0edb

Please sign in to comment.