From fac421fccabcaba6f5a86e79be71c49b9a178148 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=84=B8=ED=9D=AC/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Principal=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Tue, 3 Jul 2018 10:20:43 +0900 Subject: [PATCH] [nnkit] Help message for nni (#457) * [nnkit] Help message for nni This will show help message for arguments are invalid of nni Signed-off-by: SaeHie Park * remove --backend-arg count check --- contrib/nnkit/tools/nni/nni.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/contrib/nnkit/tools/nni/nni.cpp b/contrib/nnkit/tools/nni/nni.cpp index da37080..ba1a1e7 100644 --- a/contrib/nnkit/tools/nni/nni.cpp +++ b/contrib/nnkit/tools/nni/nni.cpp @@ -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(); -- 2.7.4