@@ -67,6 +67,8 @@ public function __construct(OutputInterface $output, $max = 0)
67
67
if (!self ::$ formats ) {
68
68
self ::$ formats = self ::initFormats ();
69
69
}
70
+
71
+ $ this ->setFormat ($ this ->determineBestFormat ());
70
72
}
71
73
72
74
/**
@@ -274,7 +276,15 @@ public function getProgressCharacter()
274
276
*/
275
277
public function setFormat ($ format )
276
278
{
277
- $ this ->format = isset (self ::$ formats [$ format ]) ? self ::$ formats [$ format ] : $ format ;
279
+ // try to use the _nomax variant if available
280
+ if (!$ this ->max && isset (self ::$ formats [$ format .'_nomax ' ])) {
281
+ $ this ->format = self ::$ formats [$ format .'_nomax ' ];
282
+ } elseif (isset (self ::$ formats [$ format ])) {
283
+ $ this ->format = self ::$ formats [$ format ];
284
+ } else {
285
+ $ this ->format = $ format ;
286
+ }
287
+
278
288
$ this ->formatLineCount = substr_count ($ this ->format , "\n" );
279
289
}
280
290
@@ -299,10 +309,6 @@ public function start()
299
309
$ this ->lastMessagesLength = 0 ;
300
310
$ this ->barCharOriginal = '' ;
301
311
302
- if (null === $ this ->format ) {
303
- $ this ->setFormat ($ this ->determineBestFormat ());
304
- }
305
-
306
312
if (!$ this ->max ) {
307
313
$ this ->barCharOriginal = $ this ->barChar ;
308
314
$ this ->barChar = $ this ->emptyBarChar ;
@@ -457,12 +463,13 @@ private function overwrite($message)
457
463
private function determineBestFormat ()
458
464
{
459
465
switch ($ this ->output ->getVerbosity ()) {
460
- case OutputInterface::VERBOSITY_QUIET :
461
- return $ this ->max > 0 ? 'quiet ' : 'quiet_nomax ' ;
466
+ // OutputInterface::VERBOSITY_QUIET: display is disabled anyway
462
467
case OutputInterface::VERBOSITY_VERBOSE :
468
+ return $ this ->max > 0 ? 'verbose ' : 'verbose_nomax ' ;
463
469
case OutputInterface::VERBOSITY_VERY_VERBOSE :
470
+ return $ this ->max > 0 ? 'very_verbose ' : 'very_verbose_nomax ' ;
464
471
case OutputInterface::VERBOSITY_DEBUG :
465
- return $ this ->max > 0 ? 'verbose ' : 'verbose_nomax ' ;
472
+ return $ this ->max > 0 ? 'debug ' : 'debug_nomax ' ;
466
473
default :
467
474
return $ this ->max > 0 ? 'normal ' : 'normal_nomax ' ;
468
475
}
@@ -528,12 +535,17 @@ private static function initPlaceholderFormatters()
528
535
private static function initFormats ()
529
536
{
530
537
return array (
531
- 'quiet ' => ' %percent%% ' ,
532
- 'normal ' => ' %current%/%max% [%bar%] %percent:3s%% ' ,
533
- 'verbose ' => ' %current%/%max% [%bar%] %percent:3s%% Elapsed: %elapsed:6s% ' ,
534
- 'quiet_nomax ' => ' %current% ' ,
535
- 'normal_nomax ' => ' %current% [%bar%] ' ,
536
- 'verbose_nomax ' => ' %current% [%bar%] Elapsed: %elapsed:6s% ' ,
538
+ 'normal ' => ' %current%/%max% [%bar%] %percent:3s%% ' ,
539
+ 'normal_nomax ' => ' %current% [%bar%] ' ,
540
+
541
+ 'verbose ' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s% ' ,
542
+ 'verbose_nomax ' => ' %current% [%bar%] %percent:3s%% %elapsed:6s% ' ,
543
+
544
+ 'very_verbose ' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s% ' ,
545
+ 'very_verbose_nomax ' => ' %current% [%bar%] %percent:3s%% %elapsed:6s% ' ,
546
+
547
+ 'debug ' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s% ' ,
548
+ 'debug_nomax ' => ' %current% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s% ' ,
537
549
);
538
550
}
539
551
}
0 commit comments