Skip to content

Commit 273ddd5

Browse files
adding help to runner
1 parent 25f8b72 commit 273ddd5

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/grbrun.in

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,34 @@ BACKENDRUNNER=(@BACKEND_RUNNER_SPACED@)
2323
declare -a ARGS
2424
SHOW="eval"
2525
BACKEND=${BACKENDS[0]}
26+
help="no"
27+
28+
function print_help {
29+
local this_bin="$1"
30+
local BACKEND=$2
31+
local RUNNER=$3
32+
33+
echo "* Runs an ALP/GraphBLAS binary by calling an underlying runner and by passing needed flags."
34+
echo
35+
echo "USAGE: ${this_bin} [ALP-specific options...] [--] [runner arguments...] <ALP/GraphBLAS binary> [binary arguments...]"
36+
echo
37+
echo "ALP-specific options:"
38+
echo " -b,--backend <backend> run against the ALP/GraphBLAS backend <backend>; possible values: ${BACKENDS[@]}; default: reference"
39+
echo " --show show the full run command WITHOUT executing it"
40+
echo " --help display this help"
41+
echo " -- <args...> pass all the following <args...> arguments directly to the underlying runner"
42+
echo
43+
echo "* Selected backend: ${BACKEND}"
44+
if [[ -z "${RUNNER}" ]]; then
45+
# shared-memory backends have no runner
46+
echo "* No custom runner: running the given ALP/GraphBLAS binary directly"
47+
else
48+
echo "* Underlying runner: ${RUNNER}"
49+
echo "* Underlying runner help:"
50+
echo
51+
exec ${RUNNER} --help
52+
fi
53+
}
2654

2755
while [[ $# -gt 0 ]]; do
2856
option="$1"
@@ -35,6 +63,9 @@ while [[ $# -gt 0 ]]; do
3563
--show)
3664
SHOW=echo
3765
;;
66+
--help)
67+
help="yes"
68+
;;
3869
--)
3970
break
4071
;;
@@ -62,4 +93,10 @@ fi
6293
RUNNER=${BACKENDRUNNER[${BACKENDID}]}
6394
LD_PATH="@ALP_UTILS_INSTALL_DIR@:${BACKENDRUNENV[${BACKENDID}]}"
6495

65-
${SHOW} LD_LIBRARY_PATH="${LD_PATH}:${LD_LIBRARY_PATH}" ${RUNNER} "${ARGS[@]}" "$@"
96+
if [[ "${help}" == "yes" ]]; then
97+
print_help "$(realpath $0)" ${BACKEND} ${RUNNER}
98+
exit 0
99+
fi
100+
101+
${SHOW} LD_LIBRARY_PATH="\"${LD_PATH}:${LD_LIBRARY_PATH}\"" ${RUNNER} "${ARGS[@]}" "$@"
102+

0 commit comments

Comments
 (0)