//
// Created by Ht on 2022/8/7.
//

#ifndef INC_1_LIBDEVCPP_MGVERSIONSHOWER_H
#define INC_1_LIBDEVCPP_MGVERSIONSHOWER_H

#include "qlibc/qlibc.h"
#include "qlibc/cmd/JCCmdRunnerHelper.h"

namespace jedge {

    class JE_API MgVersionShower {
    protected:
        std::string version_info = "0.1.0.0";
        std::string release_date = RELEASE_DATE;
        std::string app_type = "service";

    public:
        virtual const std::string& getVersionHolderName() = 0;

        void setVersionInfo(const std::string& ver, const std::string& re_date = "") {
            if(!ver.empty())
                version_info = ver;
            if(!re_date.empty())
                release_date = re_date;
        }

        std::string versionInfo() {
            std::string verInfo;
            StringUtils::formatString(verInfo, "\t\t%s %s%-6s%s \tversion %s%-6s%s @ %s%s%s", app_type.c_str(), qlog_EMark, getVersionHolderName().c_str(), qlog_LOG, qlog_EMark, version_info.c_str(), qlog_LOG, qlog_EMark, release_date.c_str(), qlog_LOG);
            return verInfo;
        }

        //显示版本信息
        bool showVersion(qlibc::JCArgNode& param) {
            FLogR("\t%s","*****************************************************************************************");
            FLogR(versionInfo().c_str());
            FLogR("\t%s","*****************************************************************************************");
            return true;
        }

    };

}

#endif //INC_1_LIBDEVCPP_MGVERSIONSHOWER_H
