aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-17 10:57:59 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-17 10:57:59 +0100
commit0eda8b794ac9a5f27b66aa0c5b6dd624e4b9ffd4 (patch)
tree7ddbc2154f363a97d32f44e03ab314548ac2b6f5
parent40d21dc768b9af290a4ee3a4d91d9b1245a4b549 (diff)
downloadpaludis-0eda8b794ac9a5f27b66aa0c5b6dd624e4b9ffd4.tar.gz
paludis-0eda8b794ac9a5f27b66aa0c5b6dd624e4b9ffd4.tar.xz
fmt sync
-rw-r--r--src/clients/cave/Makefile.am2
-rw-r--r--src/clients/cave/cmd_print_formats.cc2
-rw-r--r--src/clients/cave/cmd_sync-fmt.hh43
-rw-r--r--src/clients/cave/cmd_sync.cc41
-rw-r--r--src/clients/cave/formats.cc72
-rw-r--r--src/clients/cave/formats.hh13
6 files changed, 68 insertions, 105 deletions
diff --git a/src/clients/cave/Makefile.am b/src/clients/cave/Makefile.am
index 0d3ac6e..bc31615 100644
--- a/src/clients/cave/Makefile.am
+++ b/src/clients/cave/Makefile.am
@@ -155,7 +155,7 @@ libcave_a_SOURCES = \
cmd_search.cc cmd_search.hh \
cmd_search_cmdline.cc cmd_search_cmdline.hh \
cmd_show.cc cmd_show.hh \
- cmd_sync.cc cmd_sync.hh \
+ cmd_sync.cc cmd_sync.hh cmd_sync-fmt.hh \
cmd_uninstall.cc cmd_uninstall.hh \
cmd_update_world.cc cmd_update_world.hh \
cmd_verify.cc cmd_verify.hh cmd_verify-fmt.hh \
diff --git a/src/clients/cave/cmd_print_formats.cc b/src/clients/cave/cmd_print_formats.cc
index 7391c32..e2be9f4 100644
--- a/src/clients/cave/cmd_print_formats.cc
+++ b/src/clients/cave/cmd_print_formats.cc
@@ -114,6 +114,8 @@ namespace
}{
#include "cmd_report-fmt.hh"
}{
+#include "cmd_sync-fmt.hh"
+ }{
#include "cmd_verify-fmt.hh"
}
}
diff --git a/src/clients/cave/cmd_sync-fmt.hh b/src/clients/cave/cmd_sync-fmt.hh
new file mode 100644
index 0000000..08bf23a
--- /dev/null
+++ b/src/clients/cave/cmd_sync-fmt.hh
@@ -0,0 +1,43 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+const auto fs_heading = make_format_string_fetcher("sync/heading", 1)
+ << c::bold_blue_or_pink() << param<'s'>() << c::normal() << "\\n\\n";
+
+const auto fs_message_success = make_format_string_fetcher("sync/message_success", 1)
+ << "* " << c::bold_green_or_pink() << param<'k'>() << ":" << c::normal() << "%{column 30}" << param<'v'>() << "\\n";
+
+const auto fs_message_failure = make_format_string_fetcher("sync/message_failure", 1)
+ << "* " << c::red() << param<'k'>() << ":" << c::normal() << "%{column 30}" << param<'v'>() << "\\n";
+
+const auto fs_message_failure_message = make_format_string_fetcher("sync/message_failure_message", 1)
+ << " " << param<'s'>() << "\\n";
+
+const auto fs_repos_title = make_format_string_fetcher("sync/repos_title", 1)
+ << c::bold_normal() << "Repository%{column 30}Status%{column 52}Pending%{column 60}Active%{column 68}Done" << c::normal() << "\\n";
+
+const auto fs_repo_starting = make_format_string_fetcher("sync/repo_starting", 1)
+ << "-> " << c::bold_blue_or_pink() << param<'s'>() << c::normal() << "%{column 30}starting%{column 52}"
+ << param<'p'>() << "%{column 60}" << param<'a'>() << "%{column 68}" << param<'d'>() << c::normal() << "\\n";
+
+const auto fs_repo_done_success = make_format_string_fetcher("sync/repo_done_success", 1)
+ << "-> " << c::bold_green_or_pink() << param<'s'>() << c::normal() << "%{column 30}success%{column 52}"
+ << param<'p'>() << "%{column 60}" << param<'a'>() << "%{column 68}" << param<'d'>() << c::normal() << "\\n";
+
+const auto fs_repo_done_no_syncing_required = make_format_string_fetcher("sync/repo_done_no_syncing_required", 1)
+ << "-> " << c::bold_green_or_pink() << param<'s'>() << c::normal() << "%{column 30}no syncing required%{column 52}"
+ << param<'p'>() << "%{column 60}" << param<'a'>() << "%{column 68}" << param<'d'>() << c::normal() << "\\n";
+
+const auto fs_repo_done_failure = make_format_string_fetcher("sync/repo_done_failure", 1)
+ << "-> " << c::bold_red() << param<'s'>() << c::normal() << "%{column 30}failed%{column 52}"
+ << param<'p'>() << "%{column 60}" << param<'a'>() << "%{column 68}" << param<'d'>() << c::normal() << "\\n";
+
+const auto fs_repo_active = make_format_string_fetcher("sync/repo_active", 1)
+ << "-> " << c::bold_yellow() << param<'s'>() << c::normal() << "%{column 30}active%{column 52}"
+ << param<'p'>() << "%{column 60}" << param<'a'>() << "%{column 68}" << param<'d'>() << c::normal() << "\\n";
+
+const auto fs_repo_active_quiet = make_format_string_fetcher("sync/repo_active_quiet", 1)
+ << "-> (no output for " << param<'s'>() << " seconds)\\n";
+
+const auto fs_repo_tail = make_format_string_fetcher("sync/repo_tail", 1)
+ << " ... " << param<'s'>() << " seconds\\n";
+
diff --git a/src/clients/cave/cmd_sync.cc b/src/clients/cave/cmd_sync.cc
index 15d75f0..ddb6e2a 100644
--- a/src/clients/cave/cmd_sync.cc
+++ b/src/clients/cave/cmd_sync.cc
@@ -21,6 +21,7 @@
#include "exceptions.hh"
#include "formats.hh"
#include "format_general.hh"
+#include "format_user_config.hh"
#include <paludis/package_database.hh>
#include <paludis/util/action_queue.hh>
#include <paludis/util/mutex.hh>
@@ -56,6 +57,8 @@ using std::endl;
namespace
{
+#include "cmd_sync-fmt.hh"
+
typedef std::set<RepositoryName> Repos;
struct SyncCommandLine :
@@ -149,8 +152,8 @@ namespace
{
try
{
- cout << format_general_spad(f::sync_repo_starting(), stringify(name), executor->pending(),
- executor->active(), executor->done());
+ cout << fuc(fs_repo_starting(), fv<'s'>(stringify(name)), fv<'p'>(stringify(executor->pending())),
+ fv<'a'>(stringify(executor->active())), fv<'d'>(stringify(executor->done())));
output_manager = std::make_shared<StandardOutputManager>();
if (0 != env->perform_hook(Hook("sync_pre")
@@ -216,8 +219,8 @@ namespace
{
if (output_manager)
{
- cout << format_general_spad(f::sync_repo_active(), stringify(name), executor->pending(),
- executor->active(), executor->done());
+ cout << fuc(fs_repo_active(), fv<'s'>(stringify(name)), fv<'p'>(stringify(executor->pending())),
+ fv<'a'>(stringify(executor->active())), fv<'d'>(stringify(executor->done())));
if (output_manager->want_to_flush())
{
cout << endl;
@@ -226,8 +229,8 @@ namespace
last_output = Timestamp::now();
}
else if (! cmdline.a_sequential.specified())
- cout << format_general_s(f::sync_repo_active_quiet(),
- stringify(Timestamp::now().seconds() - last_output.seconds()));
+ cout << fuc(fs_repo_active_quiet(),
+ fv<'s'>(stringify(Timestamp::now().seconds() - last_output.seconds())));
last_flushed = Timestamp::now();
}
@@ -267,14 +270,14 @@ namespace
output_manager->nothing_more_to_come();
if (skipped)
- cout << format_general_spad(f::sync_repo_done_no_syncing_required(), stringify(name),
- executor->pending(), executor->active(), executor->done());
+ cout << fuc(fs_repo_done_no_syncing_required(), fv<'s'>(stringify(name)), fv<'p'>(stringify(executor->pending())),
+ fv<'a'>(stringify(executor->active())), fv<'d'>(stringify(executor->done())));
else if (! success)
- cout << format_general_spad(f::sync_repo_done_failure(), stringify(name),
- executor->pending(), executor->active(), executor->done());
+ cout << fuc(fs_repo_done_failure(), fv<'s'>(stringify(name)), fv<'p'>(stringify(executor->pending())),
+ fv<'a'>(stringify(executor->active())), fv<'d'>(stringify(executor->done())));
else
- cout << format_general_spad(f::sync_repo_done_success(), stringify(name),
- executor->pending(), executor->active(), executor->done());
+ cout << fuc(fs_repo_done_success(), fv<'s'>(stringify(name)), fv<'p'>(stringify(executor->pending())),
+ fv<'a'>(stringify(executor->active())), fv<'d'>(stringify(executor->done())));
}
catch (const Exception & e)
{
@@ -314,7 +317,7 @@ namespace
int retcode(0);
- cout << format_general_s(f::sync_heading(), "Sync results");
+ cout << fuc(fs_heading(), fv<'s'>("Sync results"));
for (std::list<std::shared_ptr<SyncExecutive> >::const_iterator x(executives.begin()),
x_end(executives.end()) ;
x != x_end ; ++x)
@@ -322,16 +325,16 @@ namespace
if (! (*x)->success)
{
retcode |= 1;
- cout << format_general_kv(f::sync_message_failure(), stringify((*x)->name), "failed");
- cout << format_general_s(f::sync_message_failure_message(), (*x)->error);
+ cout << fuc(fs_message_failure(), fv<'k'>(stringify((*x)->name)), fv<'v'>("failed"));
+ cout << fuc(fs_message_failure_message(), fv<'s'>((*x)->error));
}
else
{
(*x)->output_manager->succeeded();
if ((*x)->skipped)
- cout << format_general_kv(f::sync_message_success(), stringify((*x)->name), "no syncing required");
+ cout << fuc(fs_message_success(), fv<'k'>(stringify((*x)->name)), fv<'v'>("no syncing required"));
else
- cout << format_general_kv(f::sync_message_success(), stringify((*x)->name), "success");
+ cout << fuc(fs_message_success(), fv<'k'>(stringify((*x)->name)), fv<'v'>("success"));
}
(*x)->output_manager.reset();
@@ -383,14 +386,14 @@ SyncCommand::run(
if (1 == repos.size())
cmdline.a_sequential.set_specified(true);
- cout << format_general_s(f::sync_heading(), "Starting sync");
+ cout << fuc(fs_heading(), fv<'s'>("Starting sync"));
if (0 != env->perform_hook(Hook("sync_all_pre")
("TARGETS", join(repos.begin(), repos.end(), " ")),
make_null_shared_ptr()).max_exit_status())
throw SyncFailedError("Sync aborted by hook");
- cout << format_general_s(f::sync_repos_title(), "");
+ cout << fuc(fs_repos_title());
retcode |= sync_these(env, cmdline, repos);
diff --git a/src/clients/cave/formats.cc b/src/clients/cave/formats.cc
index 19dad56..6c80f15 100644
--- a/src/clients/cave/formats.cc
+++ b/src/clients/cave/formats.cc
@@ -532,75 +532,3 @@ paludis::cave::f::colour_formatter_indent()
return "%{column 30}%i%i%i%i";
}
-const std::string
-paludis::cave::f::sync_heading()
-{
- return c::bold_blue_or_pink() + "%s" + c::normal() + "\\n\\n";
-}
-
-const std::string
-paludis::cave::f::sync_message_success()
-{
- return "* " + c::bold_green_or_pink() + "%k:" + c::normal() + "%{column 30}%v\\n";
-}
-
-const std::string
-paludis::cave::f::sync_message_failure()
-{
- return "* " + c::bold_red() + "%k:" + c::normal() + "%{column 30}%v\\n";
-}
-
-const std::string
-paludis::cave::f::sync_message_failure_message()
-{
- return " %s\\n";
-}
-
-const std::string
-paludis::cave::f::sync_repos_title()
-{
- return c::bold_normal() + "Repository%{column 30}Status%{column 52}Pending%{column 60}Active%{column 68}Done" + c::normal() + "\\n";
-}
-
-const std::string
-paludis::cave::f::sync_repo_starting()
-{
- return "-> " + c::bold_blue_or_pink() + "%s" + c::normal() + "%{column 30}starting%{column 52}%p%{column 60}%a%{column 68}%d\\n";
-}
-
-const std::string
-paludis::cave::f::sync_repo_done_success()
-{
- return "-> " + c::bold_green_or_pink() + "%s" + c::normal() + "%{column 30}success%{column 52}%p%{column 60}%a%{column 68}%d\\n";
-}
-
-const std::string
-paludis::cave::f::sync_repo_done_no_syncing_required()
-{
- return "-> " + c::bold_green_or_pink() + "%s" + c::normal() + "%{column 30}no syncing required%{column 52}%p%{column 60}%a%{column 68}%d\\n";
-}
-
-const std::string
-paludis::cave::f::sync_repo_done_failure()
-{
- return "-> " + c::bold_red() + "%s" + c::normal() + "%{column 30}failed%{column 52}%p%{column 60}%a%{column 68}%d\\n";
-}
-
-const std::string
-paludis::cave::f::sync_repo_active()
-{
- 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
-paludis::cave::f::sync_repo_tail()
-{
- return " ... %s\\n";
-}
-
diff --git a/src/clients/cave/formats.hh b/src/clients/cave/formats.hh
index f79dccf..efa1f2c 100644
--- a/src/clients/cave/formats.hh
+++ b/src/clients/cave/formats.hh
@@ -139,19 +139,6 @@ namespace paludis
const std::string colour_formatter_fsentry_plain();
const std::string colour_formatter_indent();
-
- const std::string sync_heading();
- const std::string sync_message_success();
- const std::string sync_message_failure();
- const std::string sync_message_failure_message();
- const std::string sync_repos_title();
- const std::string sync_repo_starting();
- const std::string sync_repo_done_success();
- 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();
}
}
}