From 185f9b40803cb32ec02c58b6259fa1165f98b6a9 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Mon, 27 Oct 2014 20:16:44 +0100 Subject: [PATCH] Cli: Fix formatting of 'repository list' command refs #7255 --- lib/cli/objectlistcommand.cpp | 2 +- lib/cli/repositoryutility.cpp | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/cli/objectlistcommand.cpp b/lib/cli/objectlistcommand.cpp index 28c4a4652..69c9fb022 100644 --- a/lib/cli/objectlistcommand.cpp +++ b/lib/cli/objectlistcommand.cpp @@ -143,7 +143,7 @@ void ObjectListCommand::PrintObject(std::ostream& fp, bool& first, const String& fp << "Object '"; fp << ConsoleColorTag(Console_ForegroundBlue | Console_Bold) << internal_name << ConsoleColorTag(Console_Normal) << "'"; - fp << " of type '" << ConsoleColorTag(Console_ForegroundBlue | Console_Bold) << type << ConsoleColorTag(Console_Normal) << "':\n"; + fp << " of type '" << ConsoleColorTag(Console_ForegroundMagenta | Console_Bold) << type << ConsoleColorTag(Console_Normal) << "':\n"; PrintProperties(fp, properties, debug_hints, 2); diff --git a/lib/cli/repositoryutility.cpp b/lib/cli/repositoryutility.cpp index d06b778c7..f8ff2437f 100644 --- a/lib/cli/repositoryutility.cpp +++ b/lib/cli/repositoryutility.cpp @@ -133,12 +133,32 @@ void RepositoryUtility::PrintObjects(std::ostream& fp, const String& type) continue; } - fp << "Object Path: " << object << "\n"; + String file = Utility::BaseName(object); + boost::algorithm::replace_all(file, ".conf", ""); + fp << ConsoleColorTag(Console_ForegroundMagenta | Console_Bold) << type << ConsoleColorTag(Console_Normal) + << " '" << ConsoleColorTag(Console_ForegroundBlue | Console_Bold) << file << ConsoleColorTag(Console_Normal) << "'"; + + String prefix = Utility::DirName(object); + + if (type == "Service") { + std::vector tokens; + boost::algorithm::split(tokens, prefix, boost::is_any_of("/")); + + String host_name = tokens[tokens.size()-1]; + fp << " (on " << ConsoleColorTag(Console_ForegroundMagenta | Console_Bold) << "Host" << ConsoleColorTag(Console_Normal) + << " '" << ConsoleColorTag(Console_ForegroundBlue | Console_Bold) << host_name << ConsoleColorTag(Console_Normal) << "')"; + + } + + fp << "\n"; + + /* Dictionary::Ptr obj = GetObjectFromRepository(object); //TODO: config parser not implemented yet! if (obj) fp << JsonEncode(obj); + */ } } -- 2.40.0