From b1abc7fc01ee6afd7ec3c6909f26c0a1e595cad1 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 19 Aug 2022 17:00:22 +0200 Subject: [PATCH] show available commands if only command is missing --- src/utility/parse-commands.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utility/parse-commands.sh b/src/utility/parse-commands.sh index b227248f..afc7e157 100644 --- a/src/utility/parse-commands.sh +++ b/src/utility/parse-commands.sh @@ -95,7 +95,7 @@ function parse_commands_checkParameterDefinitionIsPair() { } function parseCommands { - if (($# < 5)); then + if (($# < 4)); then logError "At least five arguments need to be passed to parseCommands, given \033[0;36m%s\033[0m\nFollowing a description of the parameters:" "$#" echo >&2 '1: commands the name of an array which contains the command definitions' echo >&2 '2: version the version which shall be shown if one uses --version' @@ -113,6 +113,12 @@ function parseCommands { local -r fnPrefix=$4 shift 4 || die "could not shift by 4" + if (($# < 5 )); then + logError "no command passed to %s, following the output of --help" + echo "" + parse_commands_printHelp parseCommands_paramArr "$version" + fi + parse_commands_checkParameterDefinitionIsPair parseCommands_paramArr exitIfArgIsNotFunction "$sourceFn" 3