# HG changeset patch # User Florian Pose # Date 1216371684 0 # Node ID 9487162e4d4d3083cabd5c26cdcf745a4fa9339d # Parent fba58b99fb6a40c10b422e1000789afae32a4603 helpWanted; cmdName. diff -r fba58b99fb6a -r 9487162e4d4d tools/main.cpp --- a/tools/main.cpp Fri Jul 18 08:39:49 2008 +0000 +++ b/tools/main.cpp Fri Jul 18 09:01:24 2008 +0000 @@ -5,6 +5,7 @@ ****************************************************************************/ #include +#include // basename() #include #include @@ -17,6 +18,7 @@ #define DEFAULT_MASTER 0 +static string cmdName; static unsigned int masterIndex = DEFAULT_MASTER; static int slavePosition = -1; static int domainIndex = -1; @@ -25,13 +27,14 @@ static Master::Verbosity verbosity = Master::Normal; string dataTypeStr; bool force = false; +bool helpWanted = false; /*****************************************************************************/ void printUsage() { cerr - << "Usage: ethercat [OPTIONS]" << endl + << "Usage: " << cmdName << " [OPTIONS]" << endl << "Commands:" << endl << " alias Write alias addresses." << endl << " config Show bus configuration." << endl @@ -63,7 +66,10 @@ << " --force -f Force action." << endl << " --quiet -q Output less information." << endl << " --verbose -v Output more information." << endl - << " --help -h Show this help." << endl; + << " --help -h Show this help." << endl + << "Call '" << cmdName << " --help' for command-specific " + << "help." << endl + << "Send bug reports to " << PACKAGE_BUGREPORT << "." << endl; } /*****************************************************************************/ @@ -148,9 +154,12 @@ break; case 'h': + helpWanted = true; + break; + case '?': printUsage(); - exit(0); + exit(1); default: break; @@ -160,10 +169,12 @@ argCount = argc - optind; - if (!argCount) { - cerr << "Please specify a command!" << endl; - printUsage(); - exit(1); + if (!argCount) { + if (!helpWanted) { + cerr << "Please specify a command!" << endl; + } + printUsage(); + exit(!helpWanted); } command = argv[optind]; @@ -176,6 +187,8 @@ int main(int argc, char **argv) { Master master; + + cmdName = basename(argv[0]); getOptions(argc, argv);