Use early exit for --help and --version options.
This commit is contained in:
parent
14e7c82512
commit
70d6e0e62c
12 changed files with 282 additions and 151 deletions
|
@ -53,7 +53,6 @@
|
|||
#include "rapidjson/error/en.h"
|
||||
|
||||
|
||||
bool xmrig::ConfigLoader::m_done = false;
|
||||
xmrig::ConfigWatcher *xmrig::ConfigLoader::m_watcher = nullptr;
|
||||
xmrig::IConfigCreator *xmrig::ConfigLoader::m_creator = nullptr;
|
||||
xmrig::IConfigListener *xmrig::ConfigLoader::m_listener = nullptr;
|
||||
|
@ -239,24 +238,11 @@ bool xmrig::ConfigLoader::getJSON(const char *fileName, rapidjson::Document &doc
|
|||
|
||||
bool xmrig::ConfigLoader::parseArg(xmrig::IConfig *config, int key, const char *arg)
|
||||
{
|
||||
switch (key) {
|
||||
case xmrig::IConfig::VersionKey: /* --version */
|
||||
showVersion();
|
||||
return false;
|
||||
|
||||
case xmrig::IConfig::HelpKey: /* --help */
|
||||
showUsage();
|
||||
return false;
|
||||
|
||||
case xmrig::IConfig::ConfigKey: /* --config */
|
||||
loadFromFile(config, arg);
|
||||
break;
|
||||
|
||||
default:
|
||||
return config->parseString(key, arg);;
|
||||
if (key == xmrig::IConfig::ConfigKey) {
|
||||
return loadFromFile(config, arg);
|
||||
}
|
||||
|
||||
return true;
|
||||
return config->parseString(key, arg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -283,56 +269,3 @@ void xmrig::ConfigLoader::parseJSON(xmrig::IConfig *config, const struct option
|
|||
config->parseBoolean(option->val, value.IsTrue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::ConfigLoader::showUsage()
|
||||
{
|
||||
m_done = true;
|
||||
|
||||
printf(usage);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::ConfigLoader::showVersion()
|
||||
{
|
||||
m_done = true;
|
||||
|
||||
printf(APP_NAME " " APP_VERSION "\n built on " __DATE__
|
||||
|
||||
# if defined(__clang__)
|
||||
" with clang " __clang_version__);
|
||||
# elif defined(__GNUC__)
|
||||
" with GCC");
|
||||
printf(" %d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
||||
# elif defined(_MSC_VER)
|
||||
" with MSVC");
|
||||
printf(" %d", MSVC_VERSION);
|
||||
# else
|
||||
);
|
||||
# endif
|
||||
|
||||
printf("\n features:"
|
||||
# if defined(__i386__) || defined(_M_IX86)
|
||||
" 32-bit"
|
||||
# elif defined(__x86_64__) || defined(_M_AMD64)
|
||||
" 64-bit"
|
||||
# endif
|
||||
|
||||
# if defined(__AES__) || defined(_MSC_VER)
|
||||
" AES"
|
||||
# endif
|
||||
"\n");
|
||||
|
||||
printf("\nlibuv/%s\n", uv_version_string());
|
||||
|
||||
# ifndef XMRIG_NO_HTTPD
|
||||
printf("microhttpd/%s\n", MHD_get_version());
|
||||
# endif
|
||||
|
||||
# if !defined(XMRIG_NO_TLS) && defined(OPENSSL_VERSION_TEXT)
|
||||
{
|
||||
constexpr const char *v = OPENSSL_VERSION_TEXT + 8;
|
||||
printf("OpenSSL/%.*s\n", static_cast<int>(strchr(v, ' ') - v), v);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
|
|
@ -56,16 +56,11 @@ public:
|
|||
static IConfig *load(Process *process, IConfigCreator *creator, IConfigListener *listener);
|
||||
static void release();
|
||||
|
||||
static inline bool isDone() { return m_done; }
|
||||
|
||||
private:
|
||||
static bool getJSON(const char *fileName, rapidjson::Document &doc);
|
||||
static bool parseArg(IConfig *config, int key, const char *arg);
|
||||
static void parseJSON(IConfig *config, const struct option *option, const rapidjson::Value &object);
|
||||
static void showUsage();
|
||||
static void showVersion();
|
||||
|
||||
static bool m_done;
|
||||
static ConfigWatcher *m_watcher;
|
||||
static IConfigCreator *m_creator;
|
||||
static IConfigListener *m_listener;
|
||||
|
|
|
@ -52,7 +52,6 @@ public:
|
|||
ColorKey = 1002,
|
||||
ConfigKey = 'c',
|
||||
DonateLevelKey = 1003,
|
||||
HelpKey = 'h',
|
||||
KeepAliveKey = 'k',
|
||||
LogFileKey = 'l',
|
||||
PasswordKey = 'p',
|
||||
|
@ -66,7 +65,6 @@ public:
|
|||
UserpassKey = 'O',
|
||||
VariantKey = 1010,
|
||||
VerboseKey = 1100,
|
||||
VersionKey = 'V',
|
||||
WatchKey = 1105,
|
||||
TlsKey = 1013,
|
||||
FingerprintKey = 1014,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue