Added command-line option to output progress to stderr stream

This commit is contained in:
Robbe Derks
2018-08-13 12:54:52 +02:00
committed by Thomas Krijnen
parent 5cc5174ad5
commit 37f17b019b
+11
View File
@@ -159,6 +159,7 @@ int main(int argc, char** argv)
("version", "display version information") ("version", "display version information")
("verbose,v", "more verbose log messages") ("verbose,v", "more verbose log messages")
("quiet,q", "less status and progress output") ("quiet,q", "less status and progress output")
("stderr-progress", "output progress to stderr stream")
("yes,y", "answer 'yes' automatically to possible confirmation queries (e.g. overwriting an existing output file)") ("yes,y", "answer 'yes' automatically to possible confirmation queries (e.g. overwriting an existing output file)")
("no-progress", "suppress possible progress bar type of prints that use carriage return") ("no-progress", "suppress possible progress bar type of prints that use carriage return")
("log-format", po::value<std::string>(&log_format), "log format: plain or json"); ("log-format", po::value<std::string>(&log_format), "log format: plain or json");
@@ -343,6 +344,7 @@ int main(int argc, char** argv)
const bool verbose = vmap.count("verbose") != 0; const bool verbose = vmap.count("verbose") != 0;
const bool no_progress = vmap.count("no-progress") != 0; const bool no_progress = vmap.count("no-progress") != 0;
const bool quiet = vmap.count("quiet") != 0; const bool quiet = vmap.count("quiet") != 0;
const bool stderr_progress = vmap.count("stderr-progress") != 0;
const bool weld_vertices = vmap.count("weld-vertices") != 0; const bool weld_vertices = vmap.count("weld-vertices") != 0;
const bool use_world_coords = vmap.count("use-world-coords") != 0; const bool use_world_coords = vmap.count("use-world-coords") != 0;
const bool convert_back_units = vmap.count("convert-back-units") != 0; const bool convert_back_units = vmap.count("convert-back-units") != 0;
@@ -696,8 +698,12 @@ int main(int argc, char** argv)
const int progress = context_iterator.progress(); const int progress = context_iterator.progress();
for (; old_progress < progress; ++old_progress) { for (; old_progress < progress; ++old_progress) {
std::cout << "."; std::cout << ".";
if (stderr_progress)
std::cerr << ".";
} }
std::cout << std::flush; std::cout << std::flush;
if (stderr_progress)
std::cerr << std::flush;
} else { } else {
const int progress = context_iterator.progress() / 2; const int progress = context_iterator.progress() / 2;
if (old_progress != progress) Logger::ProgressBar(progress); if (old_progress != progress) Logger::ProgressBar(progress);
@@ -709,7 +715,12 @@ int main(int argc, char** argv)
if (!no_progress && quiet) { if (!no_progress && quiet) {
for (; old_progress < 100; ++old_progress) { for (; old_progress < 100; ++old_progress) {
std::cout << "."; std::cout << ".";
if (stderr_progress)
std::cerr << ".";
} }
std::cout << std::flush;
if (stderr_progress)
std::cerr << std::flush;
} else { } else {
Logger::Status("\rDone creating geometry (" + boost::lexical_cast<std::string>(num_created) + Logger::Status("\rDone creating geometry (" + boost::lexical_cast<std::string>(num_created) +
" objects) "); " objects) ");