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 version command to node #524

Merged
merged 2 commits into from
Dec 12, 2017
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
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