Subject: | Term::ProgressBar::Quiet should print messages even when run non-interactively |
Term::ProgressBar::Quiet's "message" sub doesn't print anything if the program is run non-interactively.
Using Term::ProgressBar, the only way to have the progress bar and the printing of regular messages not interfere with each other is to use Term::ProgressBar's sub message to print the regular messages, because printing through standard "print" interferes with the progress bar and leads to ugly results. If what you want is to always print messages but to only display a progress bar when running interactively, then Term::ProgressBar::Quiet currently does not give you what you want. Term::ProgressBar::Quiet either gives you messages and a progress bar, or no messages and no progress bar.
The documentation of Term::ProgressBar::Quiet says that it suppresses the progress bar if running non-interactively. It doesn't say that it also suppresses the output from sub message which is supposed to be very much like "print". "Print" doesn't care if the program runs interactively, so Term::ProgressBar::Quiet's sub message shouldn't, either.
If you put the code from the synopsis of Term::ProgressBar::Quiet's documentation into a perl script foo.pl and then run foo.pl, then you get a progress bar and a message "All done" (printed through "$progress->message('All done')". If you run "foo.pl | cat" instead, then you get no progress bar and no message "All done".
If the intention of Term::ProgressBar::Quiet was to suppress only the progress bar but not the messages when running non-interactively, then Term::ProgressBar::Quiet should provide a sub message that prints a message even when running non-interactively. If instead the current behavior is exactly as was intended, then the documentation should be updated to say that not just the progress bar but also the messages are suppressed when running non-interactively.
By the way, the synopsis code's "@todo = ( 'x' x 10 )" should be "@todo = ( 'x' ) x 10" instead; The former produces a list with a single element equal to 'xxxxxxxxxx' and the latter produces a list with 10 elements equal to 'x'.
By the way #2, regarding printing messages and displaying a progress bar when running interactively or non-interactively, a Term::ProgressBar::Quiet currently acts just like a Term::ProgressBar created with "silent => not(IO::Interactive::is_interactive())". If the current behavior is as intended, then the definition of Term::ProgressBar::Quiet can be changed to use Term::ProgressBar's "silent" capability, and thus remove the dependence on Test::MockObject.