Skip to content
Snippets Groups Projects
Commit 3a368183 authored by Michael Davis's avatar Michael Davis
Browse files

[cta-admin] Moves text formatting to new CtaAdminTextFormatter class

parent 2dd52c04
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,7 @@ include_directories(${CMAKE_BINARY_DIR}/eos_cta ${PROTOBUF3_INCLUDE_DIRS})
#
# cta-admin <admin_command> is the SSI version of "cta <admin_command>"
#
add_executable(cta-admin CtaAdminCmd.cpp CtaAdminCmdParse.cpp)
add_executable(cta-admin CtaAdminCmd.cpp CtaAdminCmdParse.cpp CtaAdminTextFormatter.cpp)
target_link_libraries(cta-admin XrdSsiPbEosCta XrdSsi-4 XrdSsiLib XrdUtils)
set_property (TARGET cta-admin APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH})
......
This diff is collapsed.
......@@ -43,40 +43,6 @@ public:
return is_first_record ? "[]" : "]";
}
// Static method to convert time to string
static std::string timeToString(const time_t &time)
{
std::string timeString(ctime(&time));
timeString.resize(timeString.size()-1); //remove newline
return timeString;
}
// Output headers
static void printAfLsHeader();
static void printAfLsSummaryHeader();
static void printFrLsHeader();
static void printFrLsSummaryHeader();
static void printLpaHeader();
static void printLpaSummaryHeader();
static void printLprHeader();
static void printLprSummaryHeader();
static void printTpLsHeader();
static void printTapeLsHeader();
static void printRepackLsHeader();
// Output records
static void print(const ArchiveFileLsItem &afls_item);
static void print(const ArchiveFileLsSummary &afls_summary);
static void print(const FailedRequestLsItem &frls_item);
static void print(const FailedRequestLsSummary &frls_summary);
static void print(const ListPendingArchivesItem &lpa_item);
static void print(const ListPendingArchivesSummary &lpa_summary);
static void print(const ListPendingRetrievesItem &lpr_item);
static void print(const ListPendingRetrievesSummary &lpr_summary);
static void print(const TapePoolLsItem &tpls_item);
static void print(const TapeLsItem &tals_item);
static void print(const RepackLsItem &rels_item);
private:
//! Parse the options for a specific command/subcommand
void parseOptions(int start, int argc, const char *const *const argv, const cmd_val_t &options);
......@@ -105,8 +71,6 @@ private:
static std::atomic<bool> is_json; //!< Display results in JSON format
static std::atomic<bool> is_first_record; //!< Delimiter for JSON records
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 char* const LOG_SUFFIX = "CtaAdminCmd"; //!< Identifier for log messages
};
......
This diff is collapsed.
/*!
* @project The CERN Tape Archive (CTA)
* @brief Text formatter for CTA Admin command tool
* @description CTA Admin command using Google Protocol Buffers and XRootD SSI transport
* @copyright Copyright 2019 CERN
* @license This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "CtaFrontendApi.hpp"
namespace cta {
namespace admin {
class CtaAdminTextFormatter
{
public:
// Output headers
static void printAfLsHeader();
static void printAfLsSummaryHeader();
static void printFrLsHeader();
static void printFrLsSummaryHeader();
static void printLpaHeader();
static void printLpaSummaryHeader();
static void printLprHeader();
static void printLprSummaryHeader();
static void printTpLsHeader();
static void printTapeLsHeader();
static void printRepackLsHeader();
// Output records
static void print(const ArchiveFileLsItem &afls_item);
static void print(const ArchiveFileLsSummary &afls_summary);
static void print(const FailedRequestLsItem &frls_item);
static void print(const FailedRequestLsSummary &frls_summary);
static void print(const ListPendingArchivesItem &lpa_item);
static void print(const ListPendingArchivesSummary &lpa_summary);
static void print(const ListPendingRetrievesItem &lpr_item);
static void print(const ListPendingRetrievesSummary &lpr_summary);
static void print(const TapePoolLsItem &tpls_item);
static void print(const TapeLsItem &tals_item);
static void print(const RepackLsItem &rels_item);
private:
// Static method to convert time to string
static std::string timeToString(const time_t &time)
{
std::string timeString(ctime(&time));
timeString.resize(timeString.size()-1); //remove newline
return timeString;
}
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
};
}}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment