Make `isEnvVariableSet()` public API
This commit is contained in:
parent
faaa40100c
commit
0cf59b654b
|
@ -32,27 +32,6 @@ using namespace CppUtilities::EscapeCodes;
|
|||
*/
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief Returns whether the specified env variable is set to a non-zero and non-white-space-only value.
|
||||
*/
|
||||
std::optional<bool> isEnvVariableSet(const char *variableName)
|
||||
{
|
||||
const char *envValue = std::getenv(variableName);
|
||||
if (!envValue) {
|
||||
return std::nullopt;
|
||||
}
|
||||
for (; *envValue; ++envValue) {
|
||||
switch (*envValue) {
|
||||
case '0':
|
||||
case ' ':
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief The ArgumentDenotationType enum specifies the type of a given argument denotation.
|
||||
*/
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#include "./argumentparser.h"
|
||||
#include "./commandlineutils.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace CppUtilities {
|
||||
|
||||
class CPP_UTILITIES_EXPORT ArgumentReader {
|
||||
|
@ -58,8 +56,6 @@ inline Wrapper::Wrapper(const char *str, Indentation currentIndentation)
|
|||
{
|
||||
}
|
||||
|
||||
std::optional<bool> isEnvVariableSet(const char *variableName);
|
||||
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // APPLICATION_UTILITIES_ARGUMENTPARSER_PRIVATE_H
|
||||
|
|
|
@ -43,6 +43,27 @@ bool confirmPrompt(const char *message, Response defaultResponse)
|
|||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns whether the specified env variable is set to a non-zero and non-white-space-only value.
|
||||
*/
|
||||
std::optional<bool> isEnvVariableSet(const char *variableName)
|
||||
{
|
||||
const char *envValue = std::getenv(variableName);
|
||||
if (!envValue) {
|
||||
return std::nullopt;
|
||||
}
|
||||
for (; *envValue; ++envValue) {
|
||||
switch (*envValue) {
|
||||
case '0':
|
||||
case ' ':
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns the current size of the terminal.
|
||||
* \remarks Unknown members of the returned TerminalSize are set to zero.
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "../global.h"
|
||||
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
|
@ -18,6 +19,7 @@ namespace CppUtilities {
|
|||
enum class Response { None, Yes, No };
|
||||
|
||||
CPP_UTILITIES_EXPORT bool confirmPrompt(const char *message, Response defaultResponse = Response::None);
|
||||
CPP_UTILITIES_EXPORT std::optional<bool> isEnvVariableSet(const char *variableName);
|
||||
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
CPP_UTILITIES_EXPORT bool handleVirtualTerminalProcessing();
|
||||
|
|
Loading…
Reference in New Issue