From 3987fdcea6eb34bc6dfde7831adca7bab683bc0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Tue, 30 Sep 2025 15:46:43 +0200 Subject: [PATCH 1/2] common : disable progress bar without a tty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- common/arg.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/common/arg.cpp b/common/arg.cpp index ef8a1a0f1224c..79c2d0b82ce6f 100644 --- a/common/arg.cpp +++ b/common/arg.cpp @@ -100,6 +100,14 @@ static void write_file(const std::string & fname, const std::string & content) { } } +static bool is_output_a_tty() { +#if defined(_WIN32) + return _isatty(_fileno(stdout)); +#else + return isatty(1); +#endif +} + common_arg & common_arg::set_examples(std::initializer_list examples) { this->examples = std::move(examples); return *this; @@ -660,7 +668,11 @@ static std::string show_masked_url(const common_url & parts) { return parts.scheme + "://" + (parts.user.empty() ? "" : "****:****@") + parts.host + parts.path; } -static void print_progress(size_t current, size_t total) { // TODO isatty +static void print_progress(size_t current, size_t total) { + if (!is_output_a_tty()) { + return; + } + if (!total) { return; } From d81d18a30b50e820306fcb37880434dc4f11b8bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Tue, 30 Sep 2025 16:55:38 +0200 Subject: [PATCH 2/2] Add missing headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- common/arg.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/arg.cpp b/common/arg.cpp index 79c2d0b82ce6f..172f1e3322796 100644 --- a/common/arg.cpp +++ b/common/arg.cpp @@ -54,6 +54,13 @@ #endif #define LLAMA_MAX_URL_LENGTH 2084 // Maximum URL Length in Chrome: 2083 +// isatty +#if defined(_WIN32) +#include +#else +#include +#endif + using json = nlohmann::ordered_json; std::initializer_list mmproj_examples = {