]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
common : disable progress bar without a tty (#16352)
authorAdrien Gallouët <redacted>
Tue, 30 Sep 2025 17:52:41 +0000 (19:52 +0200)
committerGitHub <redacted>
Tue, 30 Sep 2025 17:52:41 +0000 (20:52 +0300)
* common : disable progress bar without a tty

Signed-off-by: Adrien Gallouët <redacted>
* Add missing headers

Signed-off-by: Adrien Gallouët <redacted>
---------

Signed-off-by: Adrien Gallouët <redacted>
common/arg.cpp

index 3c932264d0668b1a6f6f0d9baea73dea034e5c62..8da74f909764be25ed46fecf5af70b480ef03d7d 100644 (file)
 #endif
 #define LLAMA_MAX_URL_LENGTH 2084 // Maximum URL Length in Chrome: 2083
 
+// isatty
+#if defined(_WIN32)
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
 using json = nlohmann::ordered_json;
 
 std::initializer_list<enum llama_example> mmproj_examples = {
@@ -100,6 +107,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<enum llama_example> examples) {
     this->examples = std::move(examples);
     return *this;
@@ -652,7 +667,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;
     }