[release/1.9.0][one-cmds] Handling invalid input arguments (#4213)
authorSeok Namkoong <seok9311@naver.com>
Fri, 11 Sep 2020 03:20:59 +0000 (12:20 +0900)
committerGitHub <noreply@github.com>
Fri, 11 Sep 2020 03:20:59 +0000 (12:20 +0900)
This commit will add invalid input arguments handling codes

ONE-DCO-1.0-Signed-off-by: Seok NamKoong <seok9311@naver.com>

compiler/one-cmds/one-import-bcq

index 99e7940..7b931fc 100644 (file)
@@ -38,6 +38,41 @@ version()
   exit 255
 }
 
+input_not_set()
+{
+  echo "Error: input_path not set"
+  echo ""
+  usage
+}
+
+output_not_set()
+{
+  echo "Error: output_path not set"
+  echo ""
+  usage
+}
+
+input_arrays_not_set()
+{
+  echo "Error: input_arrays not set"
+  echo ""
+  usage
+}
+
+input_shapes_not_set()
+{
+  echo "Error: input_shapes not set"
+  echo ""
+  usage
+}
+
+output_arrays_not_set()
+{
+  echo "Error: output_arrays not set"
+  echo ""
+  usage
+}
+
 TF_INTERFACE="--v1"
 
 # Parse command-line arguments
@@ -54,22 +89,37 @@ while [ "$#" -ne 0 ]; do
       ;;
     '--input_path')
       export INPUT_PATH="$2"
+      if [ $# -lt 2 ]; then
+        input_not_set
+      fi
       shift 2
       ;;
     '--output_path')
       export OUTPUT_PATH="$2"
+      if [ $# -lt 2 ]; then
+        output_not_set
+      fi
       shift 2
       ;;
     '--input_arrays')
       export INPUT_ARRAYS="$2"
+      if [ $# -lt 2 ]; then
+        input_arrays_not_set
+      fi
       shift 2
       ;;
     '--input_shapes')
       export INPUT_SHAPES="$2"
+      if [ $# -lt 2 ]; then
+        input_shapes_not_set
+      fi
       shift 2
       ;;
     '--output_arrays')
       export OUTPUT_ARRAYS="$2"
+      if [ $# -lt 2 ]; then
+        output_arrays_not_set
+      fi
       shift 2
       ;;
     '--v2')
@@ -90,6 +140,20 @@ if [ -z ${INPUT_PATH} ] || [ ! -e ${INPUT_PATH} ]; then
   exit 2
 fi
 
+if [ -z ${INPUT_ARRAYS} ]; then
+  input_arrays_not_set
+fi
+
+# INPUT_SHAPES is optional
+
+if [ -z ${OUTPUT_PATH} ]; then
+  output_not_set
+fi
+
+if [ -z ${OUTPUT_ARRAYS} ]; then
+  output_arrays_not_set
+fi
+
 FILE_BASE=$(basename ${OUTPUT_PATH})
 MODEL_NAME="${FILE_BASE%.*}"