Skip to content

Commit

Permalink
🐛 Orange indicators, better messaging logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahElliott committed Nov 5, 2024
1 parent cf36dcd commit de42333
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
1 change: 0 additions & 1 deletion .capt/share.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# Why is there no shellcheck? Doesn't seem to work well for too many things with Zsh.
pre_commit=(
# FIXME not picking up docstring
'hithere: hello $CAPT_FILES_CHANGED ## just say hello'
# 'xxx: git-confirm.sh'
# redundant with markdownlint but for testing filters etc
Expand Down
2 changes: 1 addition & 1 deletion bin/br2msg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3
print 'in br2msg'; print $COMMIT_MSG_FILE; print $COMMIT_SOURCE; print $SHA1
# print 'in br2msg'; print $COMMIT_MSG_FILE; print $COMMIT_SOURCE; print $SHA1
# If SHA1 is 'HEAD', could be in an

# FIXME might need to bail out if COMMIT_SOURCE != 'template', since 'message' is showing in problematic rebase case
Expand Down
42 changes: 27 additions & 15 deletions bin/capt
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,16 @@ setup_changes() {
dbg "git-hook arrrgs: $GITARG1 $GITARG2 $GITARG3"
}

# Look for a trailing help comment docstring ( ## ) and print if exists
# For non-built-ins, look for a trailing help comment docstring ( ## ) and print if exists
print_cmd_and_help () {
unset helpmsg
if [[ -n $CAPT_VERBOSE ]]
then cmd=$( ssed 's/ ## .*$//' <<< $cmd)
aye "$suit $fg_bold[yellow]$cmd$reset_color"
if sgrep -q ' ## ' <<< $cmd
then if sgrep -q ' ## ' <<< $cmd
then helpmsg=$( ssed 's/^.* ## //' <<< $cmd )
cmd=$( ssed 's/ ## .*$//' <<< $cmd)
aye "# $fg[yellow]$helpmsg$reset_color"
aye "$suit $fg_bold[yellow]$cmd$reset_color"
else aye "$suit $fg_bold[yellow]$cmd$reset_color"
fi
fi
}
Expand Down Expand Up @@ -489,6 +490,14 @@ run_scripts () {
if read -q "$prompt"; then failok=1; fi
# if read -k1 "$prompt"; then failok=1; fi
fi
# Set diagnostic indicators
# print "\nfailok:: $failok :: es:: $es"
if [[ $es -eq 0 ]]
then indicator='\e[38;5;2m' exclaim='SURVIVAL!' # green
elif [[ $failok -eq 1 ]]
then indicator='\e[38;5;202m' exclaim='WOUNDED! ' wounded=1 # orange
else indicator='\e[38;5;1m' exclaim='DEAD! ' # red
fi
# Bail out on whole run if any script not successful
if [[ $es -ne 0 && ! -v failok ]]; then
[[ -z $CAPT_VERBOSE ]] && print "\n${fg_bold[red]}BLIMEY!!!$reset_color\n$output"
Expand All @@ -515,21 +524,24 @@ run_scripts () {
exit $es
# aye '\(ˆ˚ˆ)/ <>_<> (-_- ;) ˚∆˚ Shiver me timbers, down to Davey Jones locker! Status:' $es; print; exit $es
else # Proceed!
if [[ $es -ne 0 && -v failok ]];
then aye "WARN: Errors detected but proceeding anyway since in ‘failok’ mode"
fi
if [[ -n $CAPT_VERBOSE ]]; then
aye "$fg[green]⚔⚔⚔ SURVIVAL! ⚔⚔⚔$reset_color" \
"$fg[$units_color](⧖ ${tfinal}${units})$reset_color\n"
else
print -n " .........." \
"$fg[green]SURVIVAL!$reset_color" \
"$fg[$units_color](⧖ ${tfinal}${units})$reset_color\n"
if [[ -n $CAPT_VERBOSE ]]
then [[ $es -ne 0 ]] && aye "WARN: Errors detected but proceeding anyway since in ‘failok’ mode"
aye "${indicator}⚔⚔⚔ $exclaim ⚔⚔⚔$reset_color" \
"$fg[$units_color](⧖ ${tfinal}${units})$reset_color\n"
else print -n " .........." \
"$indicator$exclaim$reset_color" \
"$fg[$units_color](⧖ ${tfinal}${units})$reset_color\n"
fi
fi
done

aye "$fg_bold[green]⚑⚑⚑ Ye survived the barrage. Musta been a fluke. ⚑⚑⚑ $reset_color"
if [[ -v wounded ]]
then aye "\e[1;38;5;202m⚑⚑⚑ Suffered some scathin’ ya scurvy knave. ⚑⚑⚑ $reset_color"
[[ -z $CAPT_VERBOSE ]] &&
aye "Kill yer ${EDITOR-editor} and try again with ‘CAPT_VERBOSE=1’ to see yer folly."
unset wounded failok
else aye "$fg_bold[green]⚑⚑⚑ Ye survived the barrage. Musta been a fluke. ⚑⚑⚑ $reset_color"
fi
}

# Run a set of scripts based on which hook is active
Expand Down
11 changes: 6 additions & 5 deletions bin/fixcheck
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ checks=( ${(s:,:)checks} )

# for file in `git diff --cached -p --name-status | cut -c3-`; do
for file in $@; do
if [[ ! -v CAPT_VERBOSE ]]
then print 'ERROR: Aborting since cannot run without ‘CAPT_VERBOSE=1’ set/exported'
print ' Use to bypass: export CAPT_BLACK_TRIGGERS=fixcheck'
exit 1
fi
# if [[ ! -v CAPT_VERBOSE ]]
# # FIXME Don't actually abort with this message until a fixme is detected
# then print 'ERROR: Aborting since cannot run without ‘CAPT_VERBOSE=1’ set/exported'
# print ' Use to bypass: export CAPT_BLACK_TRIGGERS=fixcheck'
# exit 1
# fi
for match_pattern in $checks; do check_file $file $match_pattern; done
if [[ -v haserror ]]; then print "ERROR: Failing due to detected violations."; exit 1; fi
done

0 comments on commit de42333

Please sign in to comment.