#!/usr/bin/env bash set -euo pipefail MAIN_DIR=$(realpath -e "$(dirname "$0")") # shellcheck disable=1091 source "$MAIN_DIR/vendor/std/src/lib.sh" std::mod::deps "$MAIN_DIR/vendor" clap source "$MAIN_DIR/src/lib.sh" eval "$(std::sensible)" # funny, this changes how $0 behaves too export CLAP_HL_SECTION=$'\033[4;1;38;2;236;134;150m' export CLAP_HL_WORD=$'\033[33m' export CLAP_HL_OPTION=$'\033[34m' declare -g TEST_COUNT=0 test::submod() { TEST_COUNT=$((TEST_COUNT + 1)) return 0 } test::name::a() { TEST_COUNT=$((TEST_COUNT + 1)) return 0 } test::name::b() { TEST_COUNT=$((TEST_COUNT + 1)) return 0 } test::name::c() { TEST_COUNT=$((TEST_COUNT + 1)) return 0 } test::name::f() { TEST_COUNT=$((TEST_COUNT + 1)) echo stdout echo error >&2 return 1 } # NOTE: be careful with return/exit here # I'm not gonna exhaustively test this one... declare -a tests__units=( test::submod test::name::a test::name::b test::name::c ) declare -a tests__clap_subcommand=() echo "=======> Check this looks fine (everything)" tests::run "$@" echo echo "=======> And this (only submod)" tests::run "$@" submod declare -a tests__units=( test::submod test::name::a test::name::b test::name::f ) tests::run submod &>/dev/null echo echo "=======> This fails, as it should" ! tests::run "$@"