[nnkit] Help message for nni (#457)
author박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Tue, 3 Jul 2018 01:20:43 +0000 (10:20 +0900)
committer박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 3 Jul 2018 01:20:43 +0000 (10:20 +0900)
* [nnkit] Help message for nni

This will show help message for arguments are invalid of nni

Signed-off-by: SaeHie Park <saehie.park@samsung.com>
* remove --backend-arg count check

contrib/nnkit/tools/nni/nni.cpp

index da37080..ba1a1e7 100644 (file)
@@ -230,7 +230,6 @@ int main(int argc, char **argv)
   //  [Command] --backend [Backend module path] --backend-arg ... --backend-arg ...
   //            --pre [Action module path] --pre-arg ... --pre-arg ...
   //            --post [Action module path] --post-arg ... --post-arg ...
-  // TODO Show usage message on invalid arguments
 
   // Argument sections
   //
@@ -278,6 +277,18 @@ int main(int argc, char **argv)
     sections.post.back().append(arg);
   };
 
+  if (argc < 2)
+  {
+    std::cerr << "Usage:" << std::endl
+              << "[Command] --backend [Backend module path] "
+              << "--backend-arg [Backend argument] ..." << std::endl
+              << "          --pre [Pre-Action module path] "
+              << "--pre-arg [Pre-Action argument] ..." << std::endl
+              << "          --post [Post-Action module path] "
+              << "--post-arg [Post-Action argument] ..." << std::endl;
+    return 255;
+  }
+
   for (int n = 1; n < argc; n += 2)
   {
     const std::string tag{argv[n]};
@@ -293,7 +304,14 @@ int main(int argc, char **argv)
 
     it->second(arg);
   }
-  
+
+  // we need a backend
+  if (sections.backend == nullptr)
+  {
+    std::cerr << "Error: Backend is required. Provide with [--backend]" << std::endl;
+    return 255;
+  }
+
   // Initialize a backend
   auto backend = sections.backend->initialize();