Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Added version number getter statement to cmake build script.
Show help when arguments aren't provided.
Never use colors when printing exceptions since we don't know if the user specified -n/--no-color in some cases.
  • Loading branch information
radj307 committed Aug 20, 2022
1 parent a239fc6 commit 7da3104
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/307lib/307modules")

include(VersionTag)
set(ENV{ckconv_VERSION} "0.0.0")
GET_VERSION_TAG("${CMAKE_CURRENT_SOURCE_DIR}" "ckconv")

project("ckconv" VERSION "${ckconv_VERSION}" LANGUAGES CXX)

Expand Down
1 change: 1 addition & 0 deletions ckconv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ file(GLOB SRCS

file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/rc")

file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/rc/version.h")
MAKE_VERSION_HEADER("${CMAKE_CURRENT_SOURCE_DIR}/rc/version.h" "ckconv" "${ckconv_VERSION}")

if (WIN32)
Expand Down
6 changes: 3 additions & 3 deletions ckconv/ckconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int main(const int argc, char** argv)
global.csync.setEnabled(!args.check_any<opt3::Flag, opt3::Option>('n', "no-color"));

// -h | --help
if (/*args.empty() || */args.check_any<opt3::Flag, opt3::Option>('h', "help")) {
if (const auto& noArgsProvided{ args.empty() }; noArgsProvided || args.check_any<opt3::Flag, opt3::Option>('h', "help")) {
std::cout << Help(programName.generic_string());
return 0;
}
Expand Down Expand Up @@ -154,10 +154,10 @@ int main(const int argc, char** argv)

return 0;
} catch (const std::exception& ex) {
std::cerr << global.csync.get_fatal() << ex.what() << std::endl;
std::cerr << term::get_fatal(false) << ex.what() << std::endl;
return 1;
} catch (...) {
std::cerr << global.csync.get_fatal() << "An undefined exception occurred!" << std::endl;
std::cerr << term::get_fatal(false) << "An undefined exception occurred!" << std::endl;
return 1;
}
}

0 comments on commit 7da3104

Please sign in to comment.