Remover requirement of passing args to help-line

This commit is contained in:
vlad 2021-12-21 11:19:51 -08:00
parent 4c54a238d8
commit b62ef700f4
4 changed files with 15 additions and 14 deletions

View File

@ -1,47 +1,47 @@
#!/usr/bin/env bash #!/usr/bin/env bash
hello() { hello() {
_help-line "Say hello!" "$@" _help-line "Say hello!"
echo Hello, world! echo Hello, world!
} }
build() { build() {
_help-line "Build an incredible script" "$@" _help-line "Build an incredible script"
mkdir -p .generated mkdir -p .generated
echo 'echo hi; echo "$@"' > .generated/potato echo 'echo hi; echo "$@"' > .generated/potato
chmod +x .generated/potato chmod +x .generated/potato
} }
run() { run() {
_help-line "Run the script" "$@" _help-line "Run the script"
build build
.generated/potato "$@" .generated/potato "$@"
} }
check() { check() {
_help-line "Verify the script passes shellcheck" "$@" _help-line "Verify the script passes shellcheck"
build build
shellcheck .generated/potato shellcheck .generated/potato
} }
test() { test() {
_help-line "Test output of the script" "$@" _help-line "Test output of the script"
build build
[ "$(.generated/potato)" == "hi" ] [ "$(.generated/potato)" == "hi" ]
} }
clean() { clean() {
_help-line "Delete generated GARBAGE" "$@" _help-line "Delete generated GARBAGE"
rm -rf .generated rm -rf .generated
} }
good() { good() {
_help-line "Show a nice message for something nice happening" "$@" _help-line "Show a nice message for something nice happening"
_good-message + Good Message _good-message + Good Message
} }
bad() { bad() {
_help-line "Show a bad message for something bad happening" "$@" _help-line "Show a bad message for something bad happening"
_bad-message - Bad Message _bad-message - Bad Message
} }
@ -64,7 +64,7 @@ kubectlw() {
} }
⚡kubectl-version() { ⚡kubectl-version() {
_help-line "Show version of kubectl wrapper" "$@" _help-line "Show version of kubectl wrapper"
kubectlw version kubectlw version
} }

4
go
View File

@ -2,7 +2,7 @@
set -euo pipefail set -euo pipefail
⚡test() { ⚡test() {
_help-line "Run all the tests" "$@" _help-line "Run all the tests"
exit=0 exit=0
for test in test/test*; do for test in test/test*; do
bash $test || exit=1 bash $test || exit=1
@ -11,7 +11,7 @@ set -euo pipefail
} }
deploy() { deploy() {
_help-line "Publish ⚡️" "$@" _help-line "Publish ⚡️"
scp ⚡ v@commandcenter.ofvlad.xyz:/srv/http/apps.ofvlad.xyz/⚡ scp ⚡ v@commandcenter.ofvlad.xyz:/srv/http/apps.ofvlad.xyz/⚡
} }

View File

@ -59,7 +59,7 @@ testHelpLinesFromDefinedCommandsAreShown() {
#!/usr/bin/env bash #!/usr/bin/env bash
⚡hello() { ⚡hello() {
_help-line "Say Hello" "$@" _help-line "Say Hello"
echo "Hello, World!" ; echo "Hello, World!" ;
} }
' > go ' > go

5
View File

@ -24,7 +24,8 @@ redefine-functions-defined-with-selector-16() {
} }
⚡help() { ⚡help() {
_help-line "Show this list" "$@" _help-line "Show this list"
export HELP_LINE=please
echo Usage: "$0" SUBCOMMAND echo Usage: "$0" SUBCOMMAND
echo echo
echo "Available subcommands:" echo "Available subcommands:"
@ -47,7 +48,7 @@ _subcommands() {
} }
_help-line() { _help-line() {
if [[ "$#" == 2 && "$2" == "help-line" ]]; then if [[ "${HELP_LINE:-}" == "please" ]]; then
echo "$1" && exit 0 echo "$1" && exit 0
fi fi
} }