diff --git a/Makefile b/Makefile index 84b9e46..2fdd36e 100644 --- a/Makefile +++ b/Makefile @@ -112,3 +112,6 @@ test-build-console-lib: build-dist sudo-install test-build-empty-app: @bash tests/bare/build/empty-app-test.sh + +test-command: + @bash tests/bare/command-test.sh diff --git a/bin/mush b/bin/mush index 6cf4710..8836c41 100644 --- a/bin/mush +++ b/bin/mush @@ -35,7 +35,7 @@ legacy getoptions VERSION="Mush 0.1.0 (2023-09-07)" parser_definition() { - setup REST help:usage abbr:true -- "Shell's build system" '' + setup REST error:args_error help:usage abbr:true -- "Shell's build system" '' msg -- 'USAGE:' " ${2##*/} [OPTIONS] [SUBCOMMAND]" '' @@ -56,6 +56,17 @@ parser_definition() { cmd publish -- "Package and upload this package to the registry" } +args_error() { + case "$2" in + notcmd) + console_error "no such command: '$3'\n\n View all available commands with 'mush --help'" + ;; + *) + echo "ERROR: ($2) $1" + esac + exit 101 +} + main() { #echo "ARGS: $@" #chmod +x target/debug/legacy/getoptions diff --git a/src/main.sh b/src/main.sh index 3e25603..266f015 100644 --- a/src/main.sh +++ b/src/main.sh @@ -14,7 +14,7 @@ legacy getoptions VERSION="Mush 0.1.0 (2023-09-07)" parser_definition() { - setup REST help:usage abbr:true -- "Shell's build system" '' + setup REST error:args_error help:usage abbr:true -- "Shell's build system" '' msg -- 'USAGE:' " ${2##*/} [OPTIONS] [SUBCOMMAND]" '' @@ -35,6 +35,17 @@ parser_definition() { cmd publish -- "Package and upload this package to the registry" } +args_error() { + case "$2" in + notcmd) + console_error "no such command: '$3'\n\n\tView all available commands with 'mush --help'" + ;; + *) + echo "ERROR: ($2) $1" + esac + exit 101 +} + main() { #echo "ARGS: $@" #chmod +x target/debug/legacy/getoptions diff --git a/target/dist/mush b/target/dist/mush index 6cf4710..8836c41 100644 --- a/target/dist/mush +++ b/target/dist/mush @@ -35,7 +35,7 @@ legacy getoptions VERSION="Mush 0.1.0 (2023-09-07)" parser_definition() { - setup REST help:usage abbr:true -- "Shell's build system" '' + setup REST error:args_error help:usage abbr:true -- "Shell's build system" '' msg -- 'USAGE:' " ${2##*/} [OPTIONS] [SUBCOMMAND]" '' @@ -56,6 +56,17 @@ parser_definition() { cmd publish -- "Package and upload this package to the registry" } +args_error() { + case "$2" in + notcmd) + console_error "no such command: '$3'\n\n View all available commands with 'mush --help'" + ;; + *) + echo "ERROR: ($2) $1" + esac + exit 101 +} + main() { #echo "ARGS: $@" #chmod +x target/debug/legacy/getoptions diff --git a/target/dist/mush.sh b/target/dist/mush.sh index 6cf4710..8836c41 100644 --- a/target/dist/mush.sh +++ b/target/dist/mush.sh @@ -35,7 +35,7 @@ legacy getoptions VERSION="Mush 0.1.0 (2023-09-07)" parser_definition() { - setup REST help:usage abbr:true -- "Shell's build system" '' + setup REST error:args_error help:usage abbr:true -- "Shell's build system" '' msg -- 'USAGE:' " ${2##*/} [OPTIONS] [SUBCOMMAND]" '' @@ -56,6 +56,17 @@ parser_definition() { cmd publish -- "Package and upload this package to the registry" } +args_error() { + case "$2" in + notcmd) + console_error "no such command: '$3'\n\n View all available commands with 'mush --help'" + ;; + *) + echo "ERROR: ($2) $1" + esac + exit 101 +} + main() { #echo "ARGS: $@" #chmod +x target/debug/legacy/getoptions diff --git a/target/dist/mush.tmp b/target/dist/mush.tmp index 6cf4710..8836c41 100755 --- a/target/dist/mush.tmp +++ b/target/dist/mush.tmp @@ -35,7 +35,7 @@ legacy getoptions VERSION="Mush 0.1.0 (2023-09-07)" parser_definition() { - setup REST help:usage abbr:true -- "Shell's build system" '' + setup REST error:args_error help:usage abbr:true -- "Shell's build system" '' msg -- 'USAGE:' " ${2##*/} [OPTIONS] [SUBCOMMAND]" '' @@ -56,6 +56,17 @@ parser_definition() { cmd publish -- "Package and upload this package to the registry" } +args_error() { + case "$2" in + notcmd) + console_error "no such command: '$3'\n\n View all available commands with 'mush --help'" + ;; + *) + echo "ERROR: ($2) $1" + esac + exit 101 +} + main() { #echo "ARGS: $@" #chmod +x target/debug/legacy/getoptions diff --git a/tests/bare/command-test.sh b/tests/bare/command-test.sh new file mode 100644 index 0000000..c01ab38 --- /dev/null +++ b/tests/bare/command-test.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -e + +echo "==> Build: mush" +cp target/debug/mush target/debug/mush.sh +bash target/debug/mush.sh build +echo "" + +echo "==> Test: no such command" +bash target/debug/mush.sh nosuchcommand