Skip to content

Commit

Permalink
[release/1.9.0][one-cmds] Handling invalid input arguments (#4213)
Browse files Browse the repository at this point in the history
This commit will add invalid input arguments handling codes

ONE-DCO-1.0-Signed-off-by: Seok NamKoong <[email protected]>
  • Loading branch information
llFreetimell authored Sep 11, 2020
1 parent 4ccaa83 commit b4aee2e
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions compiler/one-cmds/one-import-bcq
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand All @@ -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%.*}"

Expand Down

0 comments on commit b4aee2e

Please sign in to comment.