Generator version console flag
This commit is contained in:
parent
b56632b5ae
commit
792815e9ea
3 changed files with 19 additions and 1 deletions
|
@ -50,6 +50,17 @@ void DataVersion::DumpToPath(std::string const & path) const
|
|||
LOG(LINFO, ("Version of data has been written in", filePath));
|
||||
}
|
||||
|
||||
// static
|
||||
std::string DataVersion::GetCodeVersion()
|
||||
{
|
||||
base::JSONPtr json{json_object()};
|
||||
ToJSONObject(*json, "build_time", geocore::build_version::git::kTimestamp);
|
||||
ToJSONObject(*json, "git_hash", geocore::build_version::git::kHash);
|
||||
ToJSONObject(*json, "git_tag", geocore::build_version::git::kTag);
|
||||
return base::DumpToString(json);
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
DataVersion DataVersion::LoadFromPath(std::string const & path)
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
std::string GetVersionJson() const;
|
||||
void DumpToPath(std::string const & path) const;
|
||||
static DataVersion LoadFromPath(std::string const & path);
|
||||
|
||||
static std::string GetCodeVersion();
|
||||
private:
|
||||
DataVersion() = default;
|
||||
static std::string ReadWholeFile(std::string const & filePath);
|
||||
|
|
|
@ -182,6 +182,7 @@ CliCommandOptions DefineOptions(int argc, char * argv[])
|
|||
("verbose",
|
||||
po::value(&o.m_verbose)->default_value(false),
|
||||
"Provide more detailed output.")
|
||||
("version", "get version")
|
||||
("help", "produce help message");
|
||||
|
||||
po::variables_map vm;
|
||||
|
@ -195,6 +196,12 @@ CliCommandOptions DefineOptions(int argc, char * argv[])
|
|||
exit(1);
|
||||
}
|
||||
|
||||
if (vm.count("version"))
|
||||
{
|
||||
std::cout << generator::DataVersion::GetCodeVersion() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue