Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
fix: show error when 'cmd' subcommand does not match with '.glue' 'co…
Browse files Browse the repository at this point in the history
…mmands'
  • Loading branch information
hyperupcall committed May 10, 2021
1 parent fca51ec commit 16ef66c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
disable=SC1090
disable=SC2181
26 changes: 23 additions & 3 deletions lib/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,18 @@ helper_sort_files_by_when() {
# run the generic version of a particular command. for each one,
# only run the-user command file is one in 'auto' isn't present
helper_get_command_scripts() {
ensure_fn_args 'helper_get_command_and_lang_scripts' '1 2 3' "$@" || return

ensure_fn_args 'helper_get_command_scripts' '1 2 3' "$@" || return
local subcommand="$1"
local langs="$2"
local dir="$3"

shopt -q nullglob
shoptExitStatus="$?"

shopt -s nullglob

local hasRan=no

# prepend hypthen for each language
local newLangs
for l in $langs; do
newLangs+="-$l "
Expand All @@ -132,9 +134,15 @@ helper_get_command_scripts() {
# this either runs the 'auto' script or the user-override, depending
# on whether which ones are present
helper_run_a_relevant_script "$subcommand" "$dir" "$lang" "$when"
if [[ $? -eq 0 ]]; then
hasRan=yes
fi
done
done

if [[ $hasRan == no ]]; then
die "Particular subcommand '$subcommand' did not run any files"
fi

(( shoptExitStatus != 0 )) && shopt -u nullglob
}
Expand All @@ -145,12 +153,20 @@ helper_get_command_and_lang_scripts() {
local subcommand="$1"
local lang="$2"
local dir="$3"
local hasRan=no

for when in -before '' -after; do
# this either runs the 'auto' script or the user-override, depending
# on whether which ones are present
helper_run_a_relevant_script "$subcommand" "$dir" "-$lang" "$when"
if [[ $? -eq 0 ]]; then
hasRan=yes
fi
done

if [[ $hasRan == no ]]; then
die "Particular subcommand '$subcommand' did not run any files"
fi
}

helper_run_a_relevant_script() {
Expand Down Expand Up @@ -195,4 +211,8 @@ helper_run_a_relevant_script() {
done

(( shoptExitStatus != 0 )) && shopt -u nullglob

if [[ $hasRanFile == no ]]; then
return 1
fi
}

0 comments on commit 16ef66c

Please sign in to comment.