mirror of
https://github.com/TheLartians/ModernCppStarter.git
synced 2025-08-30 21:51:12 +02:00
add version information to standalone. closes #35.
This commit is contained in:
parent
1c4a8d1713
commit
b3551d686f
2 changed files with 6 additions and 1 deletions
|
@ -38,3 +38,4 @@ set_target_properties(GreeterStandalone PROPERTIES
|
|||
)
|
||||
|
||||
target_link_libraries(GreeterStandalone Greeter cxxopts)
|
||||
target_compile_definitions(GreeterStandalone PRIVATE -DGREETER_VERSION=\"${Greeter_VERSION}\")
|
||||
|
|
|
@ -21,6 +21,7 @@ int main(int argc, char** argv) {
|
|||
// clang-format off
|
||||
options.add_options()
|
||||
("h,help", "Show help")
|
||||
("v,version", "Print the current version")
|
||||
("n,name", "Name to greet", cxxopts::value(name)->default_value("World"))
|
||||
("l,lang", "Language code to use", cxxopts::value(language)->default_value("en"))
|
||||
;
|
||||
|
@ -31,11 +32,14 @@ int main(int argc, char** argv) {
|
|||
if (result["help"].as<bool>()) {
|
||||
std::cout << options.help() << std::endl;
|
||||
return 0;
|
||||
} else if (result["version"].as<bool>()) {
|
||||
std::cout << "Greeter " << GREETER_VERSION << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto langIt = languages.find(language);
|
||||
if (langIt == languages.end()) {
|
||||
std::cout << "unknown language code: " << language << std::endl;
|
||||
std::cerr << "unknown language code: " << language << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue