Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI switch to display binary version #1553

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions src/gridcoinresearchd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,8 @@ bool AppInit(int argc, char* argv[])
//
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
ParseParameters(argc, argv);
LogPrintf("AppInit");
if (!boost::filesystem::is_directory(GetDataDir(false)))
{
fprintf(stderr, "Error: Specified directory does not exist\n");
Shutdown(NULL);
}
ReadConfigFile(mapArgs, mapMultiArgs);

if (mapArgs.count("-?") || mapArgs.count("--help"))
if (mapArgs.count("-?") || mapArgs.count("-help"))
{
// First part of help message is specific to bitcoind / RPC client
std::string strUsage = _("Gridcoin version") + " " + FormatFullVersion() + "\n\n" +
Expand All @@ -78,6 +71,23 @@ bool AppInit(int argc, char* argv[])
return false;
}

if (mapArgs.count("-version"))
{
fprintf(stdout, "%s", VersionMessage().c_str());

return false;
}

LogPrintf("AppInit");

if (!boost::filesystem::is_directory(GetDataDir(false)))
{
fprintf(stderr, "Error: Specified directory does not exist\n");
Shutdown(NULL);
}

ReadConfigFile(mapArgs, mapMultiArgs);

// Command-line RPC - Test this - ensure single commands execute and exit please.
for (int i = 1; i < argc; i++)
if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "gridcoinresearchd"))
Expand Down
10 changes: 10 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ std::string HelpMessage()
//gridcoinresearch ports: testnet ? 32748 : 32749;
string strUsage = _("Options:") + "\n" +
" -? " + _("This help message") + "\n" +
" -version " + _("Print version and exit") + "\n" +
" -conf=<file> " + _("Specify configuration file (default: gridcoinresearch.conf)") + "\n" +
" -pid=<file> " + _("Specify pid file (default: gridcoind.pid)") + "\n" +
" -datadir=<dir> " + _("Specify data directory") + "\n" +
Expand Down Expand Up @@ -290,6 +291,15 @@ std::string HelpMessage()
return strUsage;
}

std::string VersionMessage()
{
// Note: this prints the version of the binary. It does not necessarily
// match the version of the running wallet when using the CLI to invoke
// RPC functions on a remote server.
//
return "Gridcoin Core " + FormatFullVersion() + "\n";
}

/** Sanity checks
* Ensure that Bitcoin is running in a usable environment with all
* necessary library support.
Expand Down
2 changes: 1 addition & 1 deletion src/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bool AppInit2(ThreadHandlerPtr threads);
void ThreadAppInit2(ThreadHandlerPtr th);

std::string HelpMessage();
std::string VersionMessage();
std::string LogSomething();


#endif
2 changes: 1 addition & 1 deletion src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ int main(int argc, char *argv[])

// Show help message immediately after parsing command-line options (for "-lang") and setting locale,
// but before showing splash screen.
if (mapArgs.count("-?") || mapArgs.count("--help"))
if (mapArgs.count("-?") || mapArgs.count("-help"))
{
GUIUtil::HelpMessageBox help;
help.showOrPrint();
Expand Down
1 change: 1 addition & 0 deletions src/qt/bitcoinstrings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ QT_TRANSLATE_NOOP("bitcoin-core", "POR Blocks Verified"),
QT_TRANSLATE_NOOP("bitcoin-core", "Password for JSON-RPC connections"),
QT_TRANSLATE_NOOP("bitcoin-core", "Please wait for new user wizard to start..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Prepend debug output with timestamp"),
QT_TRANSLATE_NOOP("bitcoin-core", "Print version and exit"),
QT_TRANSLATE_NOOP("bitcoin-core", "Project email mismatch"),
QT_TRANSLATE_NOOP("bitcoin-core", "Public Key"),
QT_TRANSLATE_NOOP("bitcoin-core", "Question"),
Expand Down
Loading