aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-03 20:16:51 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-03 20:16:51 +0000
commit395090e6d4896a3a6ba8a399d8d5f313a0ed1b54 (patch)
tree586b41ffe2033bed0fa2dd7f46b835c964d7c342
parente0f8be954b475cd2d337461f43406b0607a9f159 (diff)
downloadpaludis-395090e6d4896a3a6ba8a399d8d5f313a0ed1b54.tar.gz
paludis-395090e6d4896a3a6ba8a399d8d5f313a0ed1b54.tar.xz
Prettier output handling
-rw-r--r--src/clients/cave/cmd_sync.cc36
-rw-r--r--src/clients/cave/formats.cc8
-rw-r--r--src/clients/cave/formats.hh3
3 files changed, 35 insertions, 12 deletions
diff --git a/src/clients/cave/cmd_sync.cc b/src/clients/cave/cmd_sync.cc
index 52d4a1a..892f29c 100644
--- a/src/clients/cave/cmd_sync.cc
+++ b/src/clients/cave/cmd_sync.cc
@@ -100,7 +100,7 @@ namespace
const Executor * const executor;
const RepositoryName name;
- Timestamp last_flushed;
+ Timestamp last_flushed, last_output;
std::tr1::shared_ptr<OutputManager> output_manager;
@@ -116,7 +116,8 @@ namespace
cmdline(c),
executor(x),
name(n),
- last_flushed(0, 0)
+ last_flushed(Timestamp::now()),
+ last_output(last_flushed)
{
}
@@ -211,28 +212,43 @@ namespace
{
cout << format_general_spad(f::sync_repo_active(), stringify(name), executor->pending(),
executor->active(), executor->done());
- output_manager->flush();
+ if (output_manager->want_to_flush())
+ {
+ cout << endl;
+ output_manager->flush();
+ cout << endl;
+ last_output = Timestamp::now();
+ }
+ else
+ cout << format_general_s(f::sync_repo_active_quiet(),
+ stringify(Timestamp::now().seconds() - last_output.seconds()));
+
+ last_flushed = Timestamp::now();
}
}
virtual void flush_threaded()
{
- Timestamp now(Timestamp::now());
- if (last_flushed.seconds() + 5 < now.seconds())
- return;
- last_flushed = now;
+ if (output_manager->want_to_flush())
+ display_active();
+ else
+ {
- display_active();
+ Timestamp now(Timestamp::now());
+ if (now.seconds() - last_flushed.seconds() >= 10)
+ display_active();
+ }
}
virtual void post_execute_exclusive()
{
try
{
- if (! abort)
- {
+ if (output_manager->want_to_flush())
display_active();
+ if (! abort)
+ {
if (0 != env->perform_hook(Hook(success ? "sync_post" : "sync_fail")
("TARGET", stringify(name))
("NUMBER_DONE", stringify(executor->done()))
diff --git a/src/clients/cave/formats.cc b/src/clients/cave/formats.cc
index 351154c..45e0191 100644
--- a/src/clients/cave/formats.cc
+++ b/src/clients/cave/formats.cc
@@ -517,7 +517,13 @@ paludis::cave::f::sync_repo_done_failure()
const std::string
paludis::cave::f::sync_repo_active()
{
- return "-> %s%{column 30}active%{column 52}%p%{column 60}%a%{column 68}%d\\n";
+ return "-> " + c::bold_yellow() + "%s" + c::normal() + "%{column 30}active%{column 52}%p%{column 60}%a%{column 68}%d\\n";
+}
+
+const std::string
+paludis::cave::f::sync_repo_active_quiet()
+{
+ return "-> (no output for %s seconds)\\n";
}
const std::string
diff --git a/src/clients/cave/formats.hh b/src/clients/cave/formats.hh
index 861dcdc..2847eca 100644
--- a/src/clients/cave/formats.hh
+++ b/src/clients/cave/formats.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -139,6 +139,7 @@ namespace paludis
const std::string sync_repo_done_no_syncing_required();
const std::string sync_repo_done_failure();
const std::string sync_repo_active();
+ const std::string sync_repo_active_quiet();
const std::string sync_repo_tail();
}
}