diff --git a/cmdline/CtaAdminTextFormatter.cpp b/cmdline/CtaAdminTextFormatter.cpp index 2102aa84e8ac3918f72b142bfcaac60b484d6060..355780362d84ff3e25642d32743a4c3f33a7dda6 100644 --- a/cmdline/CtaAdminTextFormatter.cpp +++ b/cmdline/CtaAdminTextFormatter.cpp @@ -92,17 +92,18 @@ void TextFormatter::flush() { } // Output columns + bool lastColumnFlushLeft = false; for(auto &l : m_outputBuffer) { if(is_header) { std::cout << TEXT_RED; } for(size_t c = 0; c < l.size(); ++c) { - //We inserted a prefix to spot drive reasons output - bool isReason = l.at(c).find(REASON_PREFIX) != std::string::npos; - // flush right, except for paths and drive reasons, which are flush left - auto flush = ((is_header && l.at(c) == "path") || (is_header && l.at(c) == "reason") || isReason || - l.at(c).substr(0,1) == "/") ? std::left : std::right; - - if(isReason) - l.at(c).erase(0,strlen(REASON_PREFIX)); + // flush right, except for comments, paths and drive reasons, which are flush left + if(is_header && c == l.size()-1 && + (l.at(c) == "comment" || l.at(c) == "path" || l.at(c) == "reason")) { + lastColumnFlushLeft = true; + } + + auto flush = (c == l.size()-1 && lastColumnFlushLeft) ? std::left : std::right; + std::cout << std::setfill(' ') << std::setw(m_colSize.at(c)) << flush @@ -239,7 +240,7 @@ void TextFormatter::print(const DriveLsItem &drls_item) (drls_item.time_since_last_update() > DRIVE_TIMEOUT ? " [STALE]" : ""); //If there is a reason, we only want to display the beginning - std::string reason = REASON_PREFIX + cta::utils::postEllipsis(drls_item.reason(),NB_CHAR_REASON_DRIVE); + std::string reason = cta::utils::postEllipsis(drls_item.reason(),NB_CHAR_REASON_DRIVE); push_back( drls_item.logical_library(), diff --git a/cmdline/CtaAdminTextFormatter.hpp b/cmdline/CtaAdminTextFormatter.hpp index cb61333c713001c4f7962dc1ae57df2b44fa2d37..1802ecdb9b3329224aae2e3493d88b081a867fb0 100644 --- a/cmdline/CtaAdminTextFormatter.hpp +++ b/cmdline/CtaAdminTextFormatter.hpp @@ -155,7 +155,6 @@ private: static constexpr const char* const TEXT_RED = "\x1b[31;1m"; //!< Terminal formatting code for red text static constexpr const char* const TEXT_NORMAL = "\x1b[0m"; //!< Terminal formatting code for normal text static constexpr const int NB_CHAR_REASON_DRIVE = 50; //!< DriveLs reason max length to display in tabular output - static constexpr const char* const REASON_PREFIX = "REASON_"; //!< DriveLs reason prefix to be spot for left-align tabular output }; }}