jw-pkg/test/integration/jw_pkg/help/test.sh

41 lines
691 B
Shell
Raw Normal View History

#!/bin/bash
# shellcheck disable=SC2048,SC2086
# Unquoted $* and $cmds are intentional — word splitting for subcommand names
run()
{
local log_cmd
# shellcheck disable=SC2001
log_cmd=$(echo "$*" | sed 's|.*python3[0-9.]*\s\+\(\.\.\/\)*scripts/||')
printf '============= Running: %s\n' "$log_cmd"
"$@"
}
parse_subcmds()
{
$jw_pkg_py $* --help | awk '/^ [a-z]/ {print $1}'
}
help_cmd()
{
local cmds subcommand subcommands
cmds="$*"
run $jw_pkg_py $cmds --help
subcommands=$(parse_subcmds $cmds)
for subcommand in $subcommands; do
help_cmd $cmds $subcommand
done
}
cmd_test()
{
help_cmd
}
export LC_ALL="C"
set -euo pipefail
shopt -s nullglob
jw_pkg_py="$*"
cmd_test