Commit 45321a47 authored by Neil Kindlon's avatar Neil Kindlon
Browse files

Did #147: don't print usage on errors.

parent bb139717
......@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
if (btDriver.supports(subCmd)) {
if (btDriver.subMain(argc, argv)) {
return 0;
} else {
} else if (!btDriver.hadError()) {
showHelp(subCmd);
return 1;
}
......
......@@ -70,6 +70,7 @@ public:
ContextFileType getOutputFileType() const { return _outputFileType; }
virtual bool testCmdArgs(int argc, char **argv);
virtual bool errorEncountered() const { return !_errorMsg.empty(); }
//isValidState checks that parameters to context are in an acceptable state.
// If not, the error msg string will be set with a reason why it failed.
......
......@@ -24,7 +24,8 @@
#include "fisher.h"
#include "coverageFile.h"
BedtoolsDriver::BedtoolsDriver() {
BedtoolsDriver::BedtoolsDriver()
: _hadError(false) {
_supported.insert("intersect");
_supported.insert("map");
_supported.insert("closest");
......@@ -50,6 +51,7 @@ bool BedtoolsDriver::subMain(int argc, char **argv) {
//process all command line arguments, check for valid usage,
//show help and error messages if needed.
if (!context->testCmdArgs(argc - 1, argv + 1)) {
_hadError = context->errorEncountered();
delete context;
return false;
}
......
......@@ -8,9 +8,11 @@ public:
bool supports(const QuickString &tool);
ContextBase *getContext();
ToolBase *getTool(ContextBase *context);
bool hadError() const { return _hadError; }
protected:
QuickString _subCmd;
typedef set<QuickString> supportType;
supportType _supported;
bool _hadError;
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment