From 486d2c5030858bab7c31a1782b86a8e15f9bb0bb Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Thu, 6 May 2021 16:47:18 +0200 Subject: [PATCH] cli/src/main.cpp: implement "--fio" option to generate FIO keys. --- cli/src/main.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cli/src/main.cpp b/cli/src/main.cpp index 3d1f3f8..19248ac 100644 --- a/cli/src/main.cpp +++ b/cli/src/main.cpp @@ -39,6 +39,7 @@ // Command line options. bool option_l33t = false; +std::string key_prefix = "EOS"; #ifdef EOSIOKEYGEN_HAVE_THREADS size_t option_num_threads = eoskeygen::KeySearch::max_threads(); @@ -48,10 +49,10 @@ void usage(const char *name) { std::cout << std::endl << "Usage:" << std::endl - << " " << name << std::endl; + << " " << name << " [ options ]" << std::endl; std::cout << " " << name - << " search [ -m | --l33t" + << " [ options ] search [ -m | --l33t" #ifdef EOSIOKEYGEN_HAVE_THREADS << " | --threads=" #endif /* EOSIOKEYGEN_HAVE_THREADS */ @@ -60,7 +61,7 @@ void usage(const char *name) { << " ]" << std::endl; - std::cout << " " << name << " benchmark [ ]" << std::endl; + std::cout << " " << name << " [ options ] benchmark [ ]" << std::endl; std::cout << " " << name << " -h | --help" << std::endl; std::cout << " " << name << " -v" << std::endl; @@ -73,6 +74,8 @@ void usage(const char *name) { << " -h --help Shows this help text." << std::endl << std::endl << " -v Shows version." + << std::endl << std::endl + << " --fio Generate keys from FIO network instead of EOSIO." << std::endl << std::endl; std::cout << "search: " << std::endl @@ -112,7 +115,7 @@ void usage(const char *name) { int cmd_search(const eoskeygen::strlist_t& words, const eoskeygen::Dictionary& dict, int count) { eoskeygen::KeySearch ks; - eoskeygen::CliKeySearchResult rs(dict); + eoskeygen::CliKeySearchResult rs(dict, key_prefix); ks.setCallback(&rs); @@ -169,11 +172,16 @@ int main(int argc, char **argv) { // when parsing command line. int p = 1; + if (p < argc && !strcmp(argv[p], "--fio")) { + p++; + key_prefix = "FIO"; + } + // No args, just print a key. - if (argc <= 1) { + if (p >= argc) { struct libeosio::ec_keypair pair; libeosio::ec_generate_key(&pair); - libeosio::wif_print_key(&pair); + libeosio::wif_print_key(&pair, key_prefix); return 0; }