减少unsport code打印,新增git信息获取

This commit is contained in:
monktan
2020-12-29 11:36:06 +08:00
parent 871127d11a
commit 47f2f5b349
5 changed files with 63 additions and 1 deletions

View File

@@ -27,6 +27,7 @@
#include "Rtp/RtpServer.h"
#include "WebApi.h"
#include "WebHook.h"
#include "Version.h"
#if !defined(_WIN32)
#include "System.h"
@@ -154,6 +155,18 @@ public:
false,/*该选项是否必须赋值如果没有默认值且为ArgRequired时用户必须提供该参数否则将抛异常*/
"MediaServerId自定义值",/*该选项说明文字*/
nullptr);
(*_parser) << Option('v', "version", Option::ArgNone, nullptr ,false, "显示版本号",
[this](const std::shared_ptr<ostream> &stream, const string &arg){
//版本信息
*stream << "当前版本信息:" << std::endl;
*stream << "编译日期: " << build_time << std::endl;
*stream << "当前git分支: " << branch_name << std::endl;
*stream << "当前git hash值: " << commit_hash << std::endl;
stringstream ss;
ss << "\n输入\"-h\"选项获取更详细帮助";
throw std::invalid_argument(ss.str());
return false;
});
}
virtual ~CMD_main() {}