Add more details for the tidlc error cases 63/225563/1
authorhyunho <hhstark.kang@samsung.com>
Fri, 21 Feb 2020 02:30:19 +0000 (11:30 +0900)
committerhyunho <hhstark.kang@samsung.com>
Fri, 21 Feb 2020 02:30:19 +0000 (11:30 +0900)
Change-Id: Ib31d4080022f11ec1df3da83c4097cac051f3505
Signed-off-by: hyunho <hhstark.kang@samsung.com>
idlc/main.cc

index 2c405dd22d74b829587724e56399f3196e9799bc..4e19bafc6eea9c9d883ea529c08ac30c90b2468c 100644 (file)
@@ -68,6 +68,7 @@ class Options {
 
   void PrintUsage();
   void PrintVersion();
+  void PrintSample();
 
  private:
   bool isProxy_;
@@ -109,6 +110,10 @@ void Options::PrintVersion() {
   std::cerr << "tidlc " << FULLVER << std::endl;
 }
 
+void Options::PrintSample() {
+  std::cerr << "tidlc -p -l C++ -i test.tidl -o CppTestProxy " << std::endl;
+}
+
 std::unique_ptr<Options> Options::Parse(int argc, char** argv) {
   int cmd[CMD_MAX] = { 0, };
   int opt[OPT_MAX] = { 0, };
@@ -187,11 +192,31 @@ std::unique_ptr<Options> Options::Parse(int argc, char** argv) {
     return std::unique_ptr<Options>(nullptr);
   }
 
-  if (cmd[CMD_HELP] || (!cmd[CMD_PROXY] && !cmd[CMD_STUB]) ||
-       !opt[OPT_LANGUAGE] || !opt[OPT_INPUT] ||
-       !opt[OPT_OUTPUT]) {
+  if (cmd[CMD_HELP]) {
     options->PrintUsage();
     return std::unique_ptr<Options>(nullptr);
+  } else if (!cmd[CMD_PROXY] && !cmd[CMD_STUB]) {
+    std::cerr << "Stub or proxy must be specified." << std::endl;
+    options->PrintSample();
+    return std::unique_ptr<Options>(nullptr);
+  } else if (!opt[OPT_LANGUAGE]) {
+    std::cerr << "Select a language (C, C++, C#).." << std::endl;
+    options->PrintSample();
+    return std::unique_ptr<Options>(nullptr);
+  } else if (!opt[OPT_INPUT]) {
+    std::cerr << "No input file." << std::endl;
+    options->PrintSample();
+    return std::unique_ptr<Options>(nullptr);
+  } else if (opt[OPT_INPUT]) {
+    std::ifstream in_file(options->input_.c_str());
+    if (!in_file.good()) {
+      std::cerr << "Not exist input file." << std::endl;
+      return std::unique_ptr<Options>(nullptr);
+    }
+  } else if (!opt[OPT_OUTPUT]) {
+    std::cerr << "No out file." << std::endl;
+    options->PrintSample();
+    return std::unique_ptr<Options>(nullptr);
   }
 
   options->isProxy_ = cmd[CMD_PROXY] ? true : false;