From 63c018e28baf14dc57d87f42a3ac436a419ac9d3 Mon Sep 17 00:00:00 2001 From: Michael Ochmann Date: Thu, 23 Feb 2023 09:43:25 +0100 Subject: [PATCH] now printing help when called without stdin and without any parameter --- main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.cpp b/main.cpp index 93a0848..d729cf2 100644 --- a/main.cpp +++ b/main.cpp @@ -51,6 +51,7 @@ int main(int argc, char* argv[]) { massivedynamic::Type type = massivedynamic::Type::MEDIUM; massivedynamic::Format format = massivedynamic::Format::CONSOLE; bool fromStdin = true; + bool anyParameterSet = false; std::string paramData = ""; for(;;) { @@ -59,6 +60,8 @@ int main(int argc, char* argv[]) { if (result == -1) break; + + anyParameterSet = true; const option* opt = &options[index]; UNUSED(opt); switch(result) { @@ -127,6 +130,8 @@ int main(int argc, char* argv[]) { if (isatty(fileno(stdin)) || data.str().empty()) { std::cerr << "ERROR: no data from stdinput." << std::endl; + if(!anyParameterSet) + printHelp(); exit(1); } } else