diff --git a/src/intersectFile/intersectMain.cpp b/src/intersectFile/intersectMain.cpp index 030d33a854b577ead71aba798d95b85c2320f2f3..9fcb8a1b61f5f38440515e22a6a73d14d911f0d6 100644 --- a/src/intersectFile/intersectMain.cpp +++ b/src/intersectFile/intersectMain.cpp @@ -24,12 +24,14 @@ int intersect_main(int argc, char* argv[]) { Context *context = new Context(); context->parseCmdArgs(argc, argv, 1); - if (!context->isValidState()) { - fprintf(stderr, "%s\n", context->getErrorMsg().c_str()); + if (context->getShowHelp() || !context->isValidState()) { + if (!context->getErrorMsg().empty()) { + cerr << context->getErrorMsg() << endl; + } intersect_help(); + delete context; return 0; } - FileIntersect *fileIntersect = new FileIntersect(context); bool retVal = fileIntersect->intersectFiles(); diff --git a/src/utils/Contexts/Context.cpp b/src/utils/Contexts/Context.cpp index fc24bb0622483fddcb25f06e3711edecf895a47a..97143c22d847b6d97256a973097ab6376c1ba7f0 100644 --- a/src/utils/Contexts/Context.cpp +++ b/src/utils/Contexts/Context.cpp @@ -94,6 +94,10 @@ void Context::parseCmdArgs(int argc, char **argv, int skipFirstArgs) { _argc = argc; _argv = argv; _skipFirstArgs = skipFirstArgs; + if (argc < 2) { + setShowHelp(true); + return; + } _argsProcessed.resize(argc - skipFirstArgs, false);