File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 54
54
#endif
55
55
#define LLAMA_MAX_URL_LENGTH 2084 // Maximum URL Length in Chrome: 2083
56
56
57
+ // isatty
58
+ #if defined(_WIN32)
59
+ #include < io.h>
60
+ #else
61
+ #include < unistd.h>
62
+ #endif
63
+
57
64
using json = nlohmann::ordered_json;
58
65
59
66
std::initializer_list<enum llama_example> mmproj_examples = {
@@ -100,6 +107,14 @@ static void write_file(const std::string & fname, const std::string & content) {
100
107
}
101
108
}
102
109
110
+ static bool is_output_a_tty () {
111
+ #if defined(_WIN32)
112
+ return _isatty (_fileno (stdout));
113
+ #else
114
+ return isatty (1 );
115
+ #endif
116
+ }
117
+
103
118
common_arg & common_arg::set_examples (std::initializer_list<enum llama_example> examples) {
104
119
this ->examples = std::move (examples);
105
120
return *this ;
@@ -652,7 +667,11 @@ static std::string show_masked_url(const common_url & parts) {
652
667
return parts.scheme + " ://" + (parts.user .empty () ? " " : " ****:****@" ) + parts.host + parts.path ;
653
668
}
654
669
655
- static void print_progress (size_t current, size_t total) { // TODO isatty
670
+ static void print_progress (size_t current, size_t total) {
671
+ if (!is_output_a_tty ()) {
672
+ return ;
673
+ }
674
+
656
675
if (!total) {
657
676
return ;
658
677
}
You can’t perform that action at this time.
0 commit comments