From 42cc3c3a9566cd2e21bb7e6e7218b7860e081b08 Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Sat, 30 Sep 2017 23:57:55 +0200 Subject: [PATCH] add -c option for config file --- doc/usage.md | 4 ++-- xmrstak/cli/cli-miner.cpp | 33 ++++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/doc/usage.md b/doc/usage.md index dfebf21..42a29fd 100644 --- a/doc/usage.md +++ b/doc/usage.md @@ -29,9 +29,9 @@ The number of files depends on the available backends. The miner allow to overwrite some of the settings via command line options. ``` -Usage: xmr-stak [OPTION]... [CONFIGFILE] +Usage: xmr-stak [OPTION]... - -c, --config common miner configuration file + -c, --config FILE common miner configuration file -h, --help show this help --noCPU disable the CPU miner backend --cpu FILE CPU backend miner config file diff --git a/xmrstak/cli/cli-miner.cpp b/xmrstak/cli/cli-miner.cpp index 66adaf1..585b114 100644 --- a/xmrstak/cli/cli-miner.cpp +++ b/xmrstak/cli/cli-miner.cpp @@ -60,9 +60,9 @@ void help() using namespace std; using namespace xmrstak; - cout<<"Usage: "<=argc ) { - printer::inst()->print_msg(L0, "No argument for opName '--cpu' given"); + printer::inst()->print_msg(L0, "No argument for parameter '--cpu' given"); win_exit(); return 1; } @@ -150,7 +150,7 @@ int main(int argc, char *argv[]) ++i; if( i >=argc ) { - printer::inst()->print_msg(L0, "No argument for opName '--amd' given"); + printer::inst()->print_msg(L0, "No argument for parameter '--amd' given"); win_exit(); return 1; } @@ -161,7 +161,7 @@ int main(int argc, char *argv[]) ++i; if( i >=argc ) { - printer::inst()->print_msg(L0, "No argument for opName '--nvidia' given"); + printer::inst()->print_msg(L0, "No argument for parameter '--nvidia' given"); win_exit(); return 1; } @@ -172,7 +172,7 @@ int main(int argc, char *argv[]) ++i; if( i >=argc ) { - printer::inst()->print_msg(L0, "No argument for opName '-o/--url' given"); + printer::inst()->print_msg(L0, "No argument for parameter '-o/--url' given"); win_exit(); return 1; } @@ -183,7 +183,7 @@ int main(int argc, char *argv[]) ++i; if( i >=argc ) { - printer::inst()->print_msg(L0, "No argument for opName '-u/--user' given"); + printer::inst()->print_msg(L0, "No argument for parameter '-u/--user' given"); win_exit(); return 1; } @@ -194,15 +194,30 @@ int main(int argc, char *argv[]) ++i; if( i >=argc ) { - printer::inst()->print_msg(L0, "No argument for opName '-p/--pass' given"); + printer::inst()->print_msg(L0, "No argument for parameter '-p/--pass' given"); win_exit(); return 1; } userSetPasswd = true; params::inst().poolPasswd = argv[i]; } - else + else if(opName.compare("-c") == 0 || opName.compare("--config") == 0) + { + ++i; + if( i >=argc ) + { + printer::inst()->print_msg(L0, "No argument for parameter '-c/--config' given"); + win_exit(); + return 1; + } params::inst().configFile = argv[i]; + } + else + { + printer::inst()->print_msg(L0, "Parameter unknown '%s'",argv[i]); + win_exit(); + return 1; + } } // check if we need a guided start