From 5d29acb66e4cdfbd7ab0b652723da2abece648e2 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Fri, 27 Jul 2012 09:51:32 +0200 Subject: [PATCH] Avoid unnecessary shell commands with --list While the main --progress output was already hidden with the --list action, the line was still cleared after every file. This commit completely disables the progress bar when the --list option is used. --- src/cli/main.cpp | 9 +++++---- src/util/console.cpp | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cli/main.cpp b/src/cli/main.cpp index 108c57f..aa1dad9 100644 --- a/src/cli/main.cpp +++ b/src/cli/main.cpp @@ -258,7 +258,7 @@ static void process_file(const fs::path & file, const options & o) { // Print filename and size if(!o.silent) { - progress::clear(); + extract_progress.clear(); std::cout << " - "; bool named = false; @@ -285,9 +285,7 @@ static void process_file(const fs::path & file, const options & o) { } std::cout << '\n'; - if(!o.list) { - extract_progress.update(0, true); - } + extract_progress.update(0, true); } if(o.list) { @@ -471,6 +469,9 @@ int main(int argc, char * argv[]) { log_error << "cannot specify multiple actions"; return 0; } + if(o.list) { + progress::set_enabled(false); + } // Additional actions. o.dump = options.count("dump"); diff --git a/src/util/console.cpp b/src/util/console.cpp index fb00d7d..e69bab8 100644 --- a/src/util/console.cpp +++ b/src/util/console.cpp @@ -275,3 +275,7 @@ void progress::update(uint64_t delta, bool force) { #endif } + +void progress::set_enabled(bool enable) { + show_progress = enable; +}