Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call usage() with expected parameter list #782

Merged
merged 1 commit into from
Feb 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ function _check_setup {
}

function _incorrect_usage {
echo "git-secret: abort: $1"
usage
exit "$2"
local message="$1"
local exitcode="$2"
shift 2
echo "git-secret: abort: ${message}"
usage "$@"
exit "${exitcode}"
}

function _show_version {
Expand All @@ -39,7 +42,7 @@ function _show_version {

function _init_script {
if [[ $# == 0 ]]; then
_incorrect_usage 'no input parameters provided.' 126
_incorrect_usage 'no input parameters provided.' 126 "$@"
fi

# Parse plugin-level options:
Expand Down Expand Up @@ -71,7 +74,7 @@ function _init_script {
if [[ "$function_exists" == 0 ]] && [[ ! $1 == _* ]]; then
$1 "${@:2}"
else # TODO: elif [[ $(_plugin_exists $1) == 0 ]]; then
_incorrect_usage "command $1 not found." 126
_incorrect_usage "command $1 not found." 126 "$@"
fi
fi
}
Expand Down