Skip to content

Commit 0d29770

Browse files
authored
[nexus] add help and argument validation to build.sh (openthread#13133)
This commit improves the `tests/nexus/build.sh` script by adding a `display_usage()` function and implementing stricter command-line argument validation.
1 parent 6e81f1d commit 0d29770

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

tests/nexus/build.sh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@
2727
# POSSIBILITY OF SUCH DAMAGE.
2828
#
2929

30+
display_usage()
31+
{
32+
echo ""
33+
echo "Nexus Build script"
34+
echo ""
35+
echo "Usage: $(basename "$0") [config]"
36+
echo " <config> can be:"
37+
echo " (no arg) : Build OpenThread Nexus platform with default config"
38+
echo " trel : Build OpenThread Nexus platform with TREL radio (no 15.4)"
39+
echo " wasm : Build OpenThread Nexus platform for WebAssembly"
40+
echo " long_routes : Build OpenThread Nexus platform with LONG_ROUTES feature enabled"
41+
echo " no_tests : Build OpenThread Nexus platform without test executables"
42+
echo ""
43+
}
44+
3045
die()
3146
{
3247
echo " *** ERROR: " "$*"
@@ -44,6 +59,11 @@ else
4459
top_builddir=.
4560
fi
4661

62+
if [ "$#" -gt 1 ]; then
63+
display_usage
64+
exit 1
65+
fi
66+
4767
long_routes=OFF
4868
build_tests=ON
4969

@@ -66,10 +86,19 @@ case $1 in
6686
wasm=OFF
6787
build_tests=OFF
6888
;;
69-
*)
89+
"")
7090
fifteenfour=ON
7191
wasm=OFF
7292
;;
93+
help | --help | -h)
94+
display_usage
95+
exit 0
96+
;;
97+
*)
98+
echo "Error: Unknown configuration \"$1\""
99+
display_usage
100+
exit 1
101+
;;
73102
esac
74103

75104
echo "===================================================================================================="

0 commit comments

Comments
 (0)