Skip to content

Commit

Permalink
Merge pull request #524 from oxarbitrage/issue521
Browse files Browse the repository at this point in the history
add version command to node
  • Loading branch information
oxarbitrage authored Dec 12, 2017
2 parents ee06ec1 + 9c3e4f1 commit b6d95fd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions libraries/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@

#include <boost/range/adaptor/reversed.hpp>

#include <graphene/utilities/git_revision.hpp>

namespace graphene { namespace app {
using net::item_hash_t;
using net::item_id;
Expand Down Expand Up @@ -943,6 +945,7 @@ void application::set_program_options(boost::program_options::options_descriptio
("resync-blockchain", "Delete all blocks and re-sync with network from scratch")
("force-validate", "Force validation of all transactions")
("genesis-timestamp", bpo::value<uint32_t>(), "Replace timestamp from genesis.json with current time plus this many seconds (experts only!)")
("version,v", "Display version information")
;
command_line_options.add(_cli_options);
configuration_file_options.add(_cfg_options);
Expand All @@ -953,6 +956,14 @@ void application::initialize(const fc::path& data_dir, const boost::program_opti
my->_data_dir = data_dir;
my->_options = &options;

if( options.count("version") )
{
std::cout << "Version: " << graphene::utilities::git_revision_description << "\n";
std::cout << "SHA: " << graphene::utilities::git_revision_sha << "\n";
std::cout << "Timestamp: " << fc::get_approximate_relative_time_string(fc::time_point_sec(graphene::utilities::git_revision_unix_timestamp)) << "\n";
std::exit(EXIT_SUCCESS);
}

if( options.count("create-genesis-json") )
{
fc::path genesis_out = options.at("create-genesis-json").as<boost::filesystem::path>();
Expand Down
13 changes: 12 additions & 1 deletion programs/cli_wallet/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#include <fc/log/logger.hpp>
#include <fc/log/logger_config.hpp>

#include <graphene/utilities/git_revision.hpp>

#ifdef WIN32
# include <signal.h>
#else
Expand Down Expand Up @@ -79,7 +81,9 @@ int main( int argc, char** argv )
("rpc-http-endpoint,H", bpo::value<string>()->implicit_value("127.0.0.1:8093"), "Endpoint for wallet HTTP RPC to listen on")
("daemon,d", "Run the wallet in daemon mode" )
("wallet-file,w", bpo::value<string>()->implicit_value("wallet.json"), "wallet to load")
("chain-id", bpo::value<string>(), "chain ID to connect to");
("chain-id", bpo::value<string>(), "chain ID to connect to")
("version,v", "Display version information");


bpo::variables_map options;

Expand All @@ -90,6 +94,13 @@ int main( int argc, char** argv )
std::cout << opts << "\n";
return 0;
}
if( options.count("version") )
{
std::cout << "Version: " << graphene::utilities::git_revision_description << "\n";
std::cout << "SHA: " << graphene::utilities::git_revision_sha << "\n";
std::cout << "Timestamp: " << fc::get_approximate_relative_time_string(fc::time_point_sec(graphene::utilities::git_revision_unix_timestamp)) << "\n";
return 0;
}

fc::path data_dir;
fc::logging_config cfg;
Expand Down

0 comments on commit b6d95fd

Please sign in to comment.