Implemented drive_no for command-line tool; binary base name is now a

parameter of the helpString method.
This commit is contained in:
Florian Pose 2010-10-25 10:12:26 +02:00
parent a7cdeeec13
commit 18f63a581d
55 changed files with 156 additions and 96 deletions

1
TODO
View File

@ -17,7 +17,6 @@ Version 1.5.0:
- Output error after usage. - Output error after usage.
- Implement ranges for slaves and domains. - Implement ranges for slaves and domains.
* Fix casting away constness during expected WC calculation. * Fix casting away constness during expected WC calculation.
* Include SoE drive_no in ethercat tool.
Future issues: Future issues:

View File

@ -112,7 +112,7 @@ class Command
bool matchesSubstr(const string &) const; bool matchesSubstr(const string &) const;
bool matchesAbbrev(const string &) const; bool matchesAbbrev(const string &) const;
virtual string helpString() const = 0; virtual string helpString(const string &) const = 0;
typedef vector<string> StringVector; typedef vector<string> StringVector;
virtual void execute(const StringVector &) = 0; virtual void execute(const StringVector &) = 0;

View File

@ -45,11 +45,11 @@ CommandAlias::CommandAlias():
/*****************************************************************************/ /*****************************************************************************/
string CommandAlias::helpString() const string CommandAlias::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS] <ALIAS>" << endl str << binaryBaseName << " " << getName() << " [OPTIONS] <ALIAS>" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandAlias:
public: public:
CommandAlias(); CommandAlias();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
protected: protected:

View File

@ -46,11 +46,11 @@ CommandCStruct::CommandCStruct():
/*****************************************************************************/ /*****************************************************************************/
string CommandCStruct::helpString() const string CommandCStruct::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS]" << endl str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandCStruct:
public: public:
CommandCStruct(); CommandCStruct();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
protected: protected:

View File

@ -47,11 +47,11 @@ CommandConfig::CommandConfig():
/*****************************************************************************/ /*****************************************************************************/
string CommandConfig::helpString() const string CommandConfig::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS]" << endl str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -45,7 +45,7 @@ class CommandConfig:
public: public:
CommandConfig(); CommandConfig();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
protected: protected:

View File

@ -44,11 +44,11 @@ CommandData::CommandData():
/*****************************************************************************/ /*****************************************************************************/
string CommandData::helpString() const string CommandData::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS]" << endl str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandData:
public: public:
CommandData(); CommandData();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
protected: protected:

View File

@ -45,11 +45,11 @@ CommandDebug::CommandDebug():
/*****************************************************************************/ /*****************************************************************************/
string CommandDebug::helpString() const string CommandDebug::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " <LEVEL>" << endl str << binaryBaseName << " " << getName() << " <LEVEL>" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandDebug:
public: public:
CommandDebug(); CommandDebug();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
}; };

View File

@ -43,11 +43,11 @@ CommandDomains::CommandDomains():
/*****************************************************************************/ /*****************************************************************************/
string CommandDomains::helpString() const string CommandDomains::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS]" << endl str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandDomains:
public: public:
CommandDomains(); CommandDomains();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
protected: protected:

View File

@ -43,11 +43,12 @@ CommandDownload::CommandDownload():
/*****************************************************************************/ /*****************************************************************************/
string CommandDownload::helpString() const string CommandDownload::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS] <INDEX> <SUBINDEX> <VALUE>" << endl str << binaryBaseName << " " << getName()
<< " [OPTIONS] <INDEX> <SUBINDEX> <VALUE>" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandDownload:
public: public:
CommandDownload(); CommandDownload();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
protected: protected:

View File

@ -45,11 +45,11 @@ CommandEoe::CommandEoe():
/*****************************************************************************/ /*****************************************************************************/
string CommandEoe::helpString() const string CommandEoe::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << endl str << binaryBaseName << " " << getName() << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandEoe:
public: public:
CommandEoe(); CommandEoe();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
}; };

View File

@ -46,11 +46,12 @@ CommandFoeRead::CommandFoeRead():
/*****************************************************************************/ /*****************************************************************************/
string CommandFoeRead::helpString() const string CommandFoeRead::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS] <SOURCEFILE>" << endl str << binaryBaseName << " " << getName()
<< " [OPTIONS] <SOURCEFILE>" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandFoeRead:
public: public:
CommandFoeRead(); CommandFoeRead();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
}; };

View File

@ -48,11 +48,12 @@ CommandFoeWrite::CommandFoeWrite():
/*****************************************************************************/ /*****************************************************************************/
string CommandFoeWrite::helpString() const string CommandFoeWrite::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS] <FILENAME>" << endl str << binaryBaseName << " " << getName()
<< " [OPTIONS] <FILENAME>" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandFoeWrite:
public: public:
CommandFoeWrite(); CommandFoeWrite();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
protected: protected:

View File

@ -43,11 +43,11 @@ CommandGraph::CommandGraph():
/*****************************************************************************/ /*****************************************************************************/
string CommandGraph::helpString() const string CommandGraph::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS]" << endl str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandGraph:
public: public:
CommandGraph(); CommandGraph();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
}; };

View File

@ -45,11 +45,11 @@ CommandMaster::CommandMaster():
/****************************************************************************/ /****************************************************************************/
string CommandMaster::helpString() const string CommandMaster::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS]" << endl str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandMaster:
public: public:
CommandMaster(); CommandMaster();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
private: private:

View File

@ -43,11 +43,11 @@ CommandPdos::CommandPdos():
/*****************************************************************************/ /*****************************************************************************/
string CommandPdos::helpString() const string CommandPdos::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS]" << endl str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandPdos:
public: public:
CommandPdos(); CommandPdos();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
protected: protected:

View File

@ -43,11 +43,12 @@ CommandRegRead::CommandRegRead():
/*****************************************************************************/ /*****************************************************************************/
string CommandRegRead::helpString() const string CommandRegRead::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS] <OFFSET> [LENGTH]" << endl str << binaryBaseName << " " << getName()
<< " [OPTIONS] <OFFSET> [LENGTH]" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -42,7 +42,7 @@ class CommandRegRead:
public: public:
CommandRegRead(); CommandRegRead();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
}; };

View File

@ -45,11 +45,12 @@ CommandRegWrite::CommandRegWrite():
/*****************************************************************************/ /*****************************************************************************/
string CommandRegWrite::helpString() const string CommandRegWrite::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS] <OFFSET> <DATA>" << endl str << binaryBaseName << " " << getName()
<< " [OPTIONS] <OFFSET> <DATA>" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -42,7 +42,7 @@ class CommandRegWrite:
public: public:
CommandRegWrite(); CommandRegWrite();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
private: private:

View File

@ -45,11 +45,11 @@ CommandRescan::CommandRescan():
/*****************************************************************************/ /*****************************************************************************/
string CommandRescan::helpString() const string CommandRescan::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << endl str << binaryBaseName << " " << getName() << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandRescan:
public: public:
CommandRescan(); CommandRescan();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
}; };

View File

@ -43,11 +43,11 @@ CommandSdos::CommandSdos():
/*****************************************************************************/ /*****************************************************************************/
string CommandSdos::helpString() const string CommandSdos::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS]" << endl str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandSdos:
public: public:
CommandSdos(); CommandSdos();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
protected: protected:

View File

@ -43,11 +43,11 @@ CommandSiiRead::CommandSiiRead():
/*****************************************************************************/ /*****************************************************************************/
string CommandSiiRead::helpString() const string CommandSiiRead::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS]" << endl str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandSiiRead:
public: public:
CommandSiiRead(); CommandSiiRead();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
protected: protected:

View File

@ -45,11 +45,12 @@ CommandSiiWrite::CommandSiiWrite():
/*****************************************************************************/ /*****************************************************************************/
string CommandSiiWrite::helpString() const string CommandSiiWrite::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS] <FILENAME>" << endl str << binaryBaseName << " " << getName()
<< " [OPTIONS] <FILENAME>" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandSiiWrite:
public: public:
CommandSiiWrite(); CommandSiiWrite();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
protected: protected:

View File

@ -45,11 +45,11 @@ CommandSlaves::CommandSlaves():
/*****************************************************************************/ /*****************************************************************************/
string CommandSlaves::helpString() const string CommandSlaves::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS]" << endl str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandSlaves:
public: public:
CommandSlaves(); CommandSlaves();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
protected: protected:

View File

@ -28,6 +28,7 @@
****************************************************************************/ ****************************************************************************/
#include <iostream> #include <iostream>
#include <iomanip>
using namespace std; using namespace std;
#include "CommandSoeRead.h" #include "CommandSoeRead.h"
@ -42,17 +43,22 @@ CommandSoeRead::CommandSoeRead():
/*****************************************************************************/ /*****************************************************************************/
string CommandSoeRead::helpString() const string CommandSoeRead::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS] <IDN>" << endl str << binaryBaseName << " " << getName()
<< " [OPTIONS] <IDN>" << endl
<< binaryBaseName << " " << getName()
<< " [OPTIONS] <DRIVE> <IDN>" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl
<< "This command requires a single slave to be selected." << endl << "This command requires a single slave to be selected." << endl
<< endl << endl
<< "Arguments:" << endl << "Arguments:" << endl
<< " DRIVE is the drive number (0 - 7). If omitted, 0 is assumed."
<< endl
<< " IDN is the IDN and must be either an unsigned" << endl << " IDN is the IDN and must be either an unsigned" << endl
<< " 16 bit number acc. to IEC 61800-7-204:" << endl << " 16 bit number acc. to IEC 61800-7-204:" << endl
<< " Bit 15: (0) Standard data, (1) Product data" << endl << " Bit 15: (0) Standard data, (1) Product data" << endl
@ -84,18 +90,38 @@ void CommandSoeRead::execute(const StringVector &args)
stringstream err; stringstream err;
const DataType *dataType = NULL; const DataType *dataType = NULL;
ec_ioctl_slave_soe_read_t ioctl; ec_ioctl_slave_soe_read_t ioctl;
int driveArgIndex = -1, idnArgIndex = -1;
if (args.size() != 1) { if (args.size() == 1) {
err << "'" << getName() << "' takes one argument!"; idnArgIndex = 0;
} else if (args.size() == 2) {
driveArgIndex = 0;
idnArgIndex = 1;
} else {
err << "'" << getName() << "' takes eiter 1 or 2 arguments!";
throwInvalidUsageException(err); throwInvalidUsageException(err);
} }
ioctl.drive_no = 0; // FIXME if (driveArgIndex >= 0) {
stringstream str;
unsigned int number;
str << args[driveArgIndex];
str
>> resetiosflags(ios::basefield) // guess base from prefix
>> number;
if (str.fail() || number > 7) {
err << "Invalid drive number '" << args[driveArgIndex] << "'!";
throwInvalidUsageException(err);
}
ioctl.drive_no = number;
} else {
ioctl.drive_no = 0;
}
try { try {
ioctl.idn = parseIdn(args[0]); ioctl.idn = parseIdn(args[idnArgIndex]);
} catch (runtime_error &e) { } catch (runtime_error &e) {
err << "Invalid IDN '" << args[0] << "': " << e.what(); err << "Invalid IDN '" << args[idnArgIndex] << "': " << e.what();
throwInvalidUsageException(err); throwInvalidUsageException(err);
} }

View File

@ -42,7 +42,7 @@ class CommandSoeRead:
public: public:
CommandSoeRead(); CommandSoeRead();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
}; };

View File

@ -28,6 +28,7 @@
****************************************************************************/ ****************************************************************************/
#include <iostream> #include <iostream>
#include <iomanip>
using namespace std; using namespace std;
#include "CommandSoeWrite.h" #include "CommandSoeWrite.h"
@ -42,17 +43,22 @@ CommandSoeWrite::CommandSoeWrite():
/*****************************************************************************/ /*****************************************************************************/
string CommandSoeWrite::helpString() const string CommandSoeWrite::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS] <IDN> <VALUE>" << endl str << binaryBaseName << " " << getName()
<< " [OPTIONS] <IDN> <VALUE>" << endl
<< binaryBaseName << " " << getName()
<< " [OPTIONS] <DRIVE> <IDN> <VALUE>" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl
<< "This command requires a single slave to be selected." << endl << "This command requires a single slave to be selected." << endl
<< endl << endl
<< "Arguments:" << endl << "Arguments:" << endl
<< " DRIVE is the drive number (0 - 7). If omitted, 0 is assumed."
<< endl
<< " IDN is the IDN and must be either an unsigned" << endl << " IDN is the IDN and must be either an unsigned" << endl
<< " 16 bit number acc. to IEC 61800-7-204:" << endl << " 16 bit number acc. to IEC 61800-7-204:" << endl
<< " Bit 15: (0) Standard data, (1) Product data" << endl << " Bit 15: (0) Standard data, (1) Product data" << endl
@ -81,23 +87,45 @@ string CommandSoeWrite::helpString() const
void CommandSoeWrite::execute(const StringVector &args) void CommandSoeWrite::execute(const StringVector &args)
{ {
stringstream strIdn, err; stringstream err;
const DataType *dataType = NULL; const DataType *dataType = NULL;
ec_ioctl_slave_soe_write_t ioctl; ec_ioctl_slave_soe_write_t ioctl;
SlaveList slaves; SlaveList slaves;
size_t memSize; size_t memSize;
int driveArgIndex = -1, idnArgIndex = -1, valueArgIndex = -1;
if (args.size() != 2) { if (args.size() == 2) {
err << "'" << getName() << "' takes 2 arguments!"; idnArgIndex = 0;
valueArgIndex = 1;
} else if (args.size() == 3) {
driveArgIndex = 0;
idnArgIndex = 1;
valueArgIndex = 2;
} else {
err << "'" << getName() << "' takes eiter 2 or 3 arguments!";
throwInvalidUsageException(err); throwInvalidUsageException(err);
} }
ioctl.drive_no = 0; // FIXME if (driveArgIndex >= 0) {
stringstream str;
unsigned int number;
str << args[driveArgIndex];
str
>> resetiosflags(ios::basefield) // guess base from prefix
>> number;
if (str.fail() || number > 7) {
err << "Invalid drive number '" << args[driveArgIndex] << "'!";
throwInvalidUsageException(err);
}
ioctl.drive_no = number;
} else {
ioctl.drive_no = 0;
}
try { try {
ioctl.idn = parseIdn(args[0]); ioctl.idn = parseIdn(args[idnArgIndex]);
} catch (runtime_error &e) { } catch (runtime_error &e) {
err << "Invalid IDN '" << args[0] << "': " << e.what(); err << "Invalid IDN '" << args[idnArgIndex] << "': " << e.what();
throwInvalidUsageException(err); throwInvalidUsageException(err);
} }
@ -123,7 +151,7 @@ void CommandSoeWrite::execute(const StringVector &args)
memSize = dataType->byteSize; memSize = dataType->byteSize;
} else { } else {
// guess string type size // guess string type size
memSize = args[1].size() + 1; memSize = args[valueArgIndex].size() + 1;
if (!memSize) { if (!memSize) {
err << "Empty argument not allowed."; err << "Empty argument not allowed.";
throwInvalidUsageException(err); throwInvalidUsageException(err);
@ -134,13 +162,13 @@ void CommandSoeWrite::execute(const StringVector &args)
try { try {
ioctl.data_size = interpretAsType( ioctl.data_size = interpretAsType(
dataType, args[1], ioctl.data, memSize); dataType, args[valueArgIndex], ioctl.data, memSize);
} catch (SizeException &e) { } catch (SizeException &e) {
delete [] ioctl.data; delete [] ioctl.data;
throwCommandException(e.what()); throwCommandException(e.what());
} catch (ios::failure &e) { } catch (ios::failure &e) {
delete [] ioctl.data; delete [] ioctl.data;
err << "Invalid value argument '" << args[1] err << "Invalid value argument '" << args[valueArgIndex]
<< "' for type '" << dataType->name << "'!"; << "' for type '" << dataType->name << "'!";
throwInvalidUsageException(err); throwInvalidUsageException(err);
} }

View File

@ -42,7 +42,7 @@ class CommandSoeWrite:
public: public:
CommandSoeWrite(); CommandSoeWrite();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
}; };

View File

@ -43,11 +43,11 @@ CommandStates::CommandStates():
/*****************************************************************************/ /*****************************************************************************/
string CommandStates::helpString() const string CommandStates::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS] <STATE>" << endl str << binaryBaseName << " " << getName() << " [OPTIONS] <STATE>" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandStates:
public: public:
CommandStates(); CommandStates();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
}; };

View File

@ -43,11 +43,12 @@ CommandUpload::CommandUpload():
/*****************************************************************************/ /*****************************************************************************/
string CommandUpload::helpString() const string CommandUpload::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS] <INDEX> <SUBINDEX>" << endl str << binaryBaseName << " " << getName()
<< " [OPTIONS] <INDEX> <SUBINDEX>" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandUpload:
public: public:
CommandUpload(); CommandUpload();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
protected: protected:

View File

@ -41,11 +41,11 @@ CommandVersion::CommandVersion():
/****************************************************************************/ /****************************************************************************/
string CommandVersion::helpString() const string CommandVersion::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS]" << endl str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
<< endl << endl
<< getBriefDescription() << endl; << getBriefDescription() << endl;

View File

@ -40,7 +40,7 @@ class CommandVersion:
public: public:
CommandVersion(); CommandVersion();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
}; };

View File

@ -44,11 +44,11 @@ CommandXml::CommandXml():
/*****************************************************************************/ /*****************************************************************************/
string CommandXml::helpString() const string CommandXml::helpString(const string &binaryBaseName) const
{ {
stringstream str; stringstream str;
str << getName() << " [OPTIONS]" << endl str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
<< endl << endl
<< getBriefDescription() << endl << getBriefDescription() << endl
<< endl << endl

View File

@ -40,7 +40,7 @@ class CommandXml:
public: public:
CommandXml(); CommandXml();
string helpString() const; string helpString(const string &) const;
void execute(const StringVector &); void execute(const StringVector &);
protected: protected:

View File

@ -340,7 +340,7 @@ int main(int argc, char **argv)
cmd->execute(commandArgs); cmd->execute(commandArgs);
} catch (InvalidUsageException &e) { } catch (InvalidUsageException &e) {
cerr << e.what() << endl << endl; cerr << e.what() << endl << endl;
cerr << binaryBaseName << " " << cmd->helpString(); cerr << cmd->helpString(binaryBaseName);
retval = 1; retval = 1;
} catch (CommandException &e) { } catch (CommandException &e) {
cerr << e.what() << endl; cerr << e.what() << endl;
@ -350,7 +350,7 @@ int main(int argc, char **argv)
retval = 1; retval = 1;
} }
} else { } else {
cout << binaryBaseName << " " << cmd->helpString(); cout << cmd->helpString(binaryBaseName);
} }
} else { } else {
cerr << "Ambiguous command abbreviation! Matching:" << endl; cerr << "Ambiguous command abbreviation! Matching:" << endl;