Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion common/arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<enum llama_example> examples) {
this->examples = std::move(examples);
return *this;
Expand Down Expand Up @@ -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;
}
Expand Down
Loading