Allow specifying custom exit() function
This commit is contained in:
parent
438ca48cbb
commit
a1189d3c3b
|
@ -111,8 +111,8 @@ set(META_APP_AUTHOR "Martchus")
|
||||||
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
||||||
set(META_APP_DESCRIPTION "Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities")
|
set(META_APP_DESCRIPTION "Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities")
|
||||||
set(META_VERSION_MAJOR 4)
|
set(META_VERSION_MAJOR 4)
|
||||||
set(META_VERSION_MINOR 2)
|
set(META_VERSION_MINOR 3)
|
||||||
set(META_VERSION_PATCH 1)
|
set(META_VERSION_PATCH 0)
|
||||||
|
|
||||||
# find required 3rd party libraries
|
# find required 3rd party libraries
|
||||||
include(3rdParty)
|
include(3rdParty)
|
||||||
|
|
|
@ -33,6 +33,12 @@ const char *applicationVersion = nullptr;
|
||||||
/// \brief Specifies the URL to the application website (used by ArgumentParser::printHelp()).
|
/// \brief Specifies the URL to the application website (used by ArgumentParser::printHelp()).
|
||||||
const char *applicationUrl = nullptr;
|
const char *applicationUrl = nullptr;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Specifies a function quit the application.
|
||||||
|
* \remarks Currently only used after printing Bash completion. Default is std::exit().
|
||||||
|
*/
|
||||||
|
void(*exitFunction)(int) = &exit;
|
||||||
|
|
||||||
/// \cond
|
/// \cond
|
||||||
|
|
||||||
inline bool notEmpty(const char *str)
|
inline bool notEmpty(const char *str)
|
||||||
|
@ -429,7 +435,7 @@ void ArgumentParser::readArgs(int argc, const char * const *argv)
|
||||||
|
|
||||||
if(completionMode) {
|
if(completionMode) {
|
||||||
printBashCompletion(argc, argv, currentWordIndex, lastDetectedArgument);
|
printBashCompletion(argc, argv, currentWordIndex, lastDetectedArgument);
|
||||||
exit(0); // prevent the applicaton to continue with the regular execution
|
exitFunction(0); // prevent the applicaton to continue with the regular execution
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// no arguments specified -> flag default argument as present if one is assigned
|
// no arguments specified -> flag default argument as present if one is assigned
|
||||||
|
|
|
@ -30,6 +30,8 @@ CPP_UTILITIES_EXPORT extern const char *applicationUrl;
|
||||||
::ApplicationUtilities::applicationVersion = APP_VERSION; \
|
::ApplicationUtilities::applicationVersion = APP_VERSION; \
|
||||||
::ApplicationUtilities::applicationUrl = APP_URL
|
::ApplicationUtilities::applicationUrl = APP_URL
|
||||||
|
|
||||||
|
CPP_UTILITIES_EXPORT extern void(*exitFunction)(int);
|
||||||
|
|
||||||
class Argument;
|
class Argument;
|
||||||
class ArgumentParser;
|
class ArgumentParser;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue