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 5454#endif
5555#define LLAMA_MAX_URL_LENGTH 2084 // Maximum URL Length in Chrome: 2083
5656
57+ // isatty
58+ #if defined(_WIN32)
59+ #include < io.h>
60+ #else
61+ #include < unistd.h>
62+ #endif
63+
5764using json = nlohmann::ordered_json;
5865
5966std::initializer_list<enum llama_example> mmproj_examples = {
@@ -100,6 +107,14 @@ static void write_file(const std::string & fname, const std::string & content) {
100107 }
101108}
102109
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+
103118common_arg & common_arg::set_examples (std::initializer_list<enum llama_example> examples) {
104119 this ->examples = std::move (examples);
105120 return *this ;
@@ -652,7 +667,11 @@ static std::string show_masked_url(const common_url & parts) {
652667 return parts.scheme + " ://" + (parts.user .empty () ? " " : " ****:****@" ) + parts.host + parts.path ;
653668}
654669
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+
656675 if (!total) {
657676 return ;
658677 }
You can’t perform that action at this time.
0 commit comments