From 270998893ac42e3ae1101e5d020f912b1965cd01 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Fri, 14 Nov 2014 15:09:33 -0800 Subject: [PATCH] Make format validator cmdarg-2.0 compliant --- bin/shunit.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/shunit.sh b/bin/shunit.sh index ab8b98a..32618f7 100644 --- a/bin/shunit.sh +++ b/bin/shunit.sh @@ -2,10 +2,16 @@ source /usr/lib/cmdarg.sh +function validate_format +{ + echo $1 | grep -E "^junit$|^tunit$" >/dev/null 2>&1 + return $? +} + cmdarg_info author "Andrew Kesterson " cmdarg_info header "A bash script for unit testing other bash scripts in JUNIT or human-friendly formats" cmdarg_info copyright "(MIT License)" -cmdarg 'f:' 'format' 'Format to print results in. Valid options are: [junit, tunit]' 'junit' 'echo ${OPTARG} | grep -E "^junit$|^tunit$" >/dev/null 2>&1' +cmdarg 'f:' 'format' 'Format to print results in. Valid options are: [junit, tunit]' 'junit' validate_format cmdarg 't:' 'tests' 'Directory or single file to test.' cmdarg_parse "$@"