add type target
This commit is contained in:
24
bake
24
bake
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
## VERSION 23.8.23
|
## VERSION 25.11.28
|
||||||
## BASH-MAKE ==========================================================
|
## BASH-MAKE ==========================================================
|
||||||
## Utility to mimick some of GNU Make behavior, but run in a single
|
## Utility to mimick some of GNU Make behavior, but run in a single
|
||||||
## bash shell. This executable can be used as the Bakefile, too,
|
## bash shell. This executable can be used as the Bakefile, too,
|
||||||
@@ -51,6 +51,26 @@ _menu() { _flines | while read line; do
|
|||||||
"${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}"
|
"${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}"
|
||||||
fi
|
fi
|
||||||
done; }
|
done; }
|
||||||
|
_type() { if [ -z "$1" ]; then echo Give target name; exit 1; fi;
|
||||||
|
OLDIFS="$IFS"
|
||||||
|
IFS=''
|
||||||
|
while read line; do
|
||||||
|
if [[ "$line" =~ ([a-zA-Z0-9_\.\-]+)\(\).\{[\ #]*(.*) ]]; then
|
||||||
|
if [ "${BASH_REMATCH[1]}" = "$1" ]; then
|
||||||
|
infunction=true
|
||||||
|
printf "\e[33m%s\e[0m() {\e[36m # %-50s ]\e[0m\n" \
|
||||||
|
"${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}"
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
infunction=false
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "$infunction" = "true" ]; then
|
||||||
|
if [ -z "$line" ]; then continue; fi
|
||||||
|
echo "$line"
|
||||||
|
fi
|
||||||
|
done < "$BAKEFILE"
|
||||||
|
IFS="$OLDIFS"; }
|
||||||
_help() {
|
_help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Bash-Make: bake
|
Bash-Make: bake
|
||||||
@@ -59,6 +79,7 @@ Bash-Make: bake
|
|||||||
-h This help. Add function name to get help for the target.
|
-h This help. Add function name to get help for the target.
|
||||||
-f [Bakefile] Choose a different Bakefile than the default.
|
-f [Bakefile] Choose a different Bakefile than the default.
|
||||||
-l List targets
|
-l List targets
|
||||||
|
-t [target] Type target
|
||||||
-m Menu of targets with 'smenu' command
|
-m Menu of targets with 'smenu' command
|
||||||
__autocomplete__ get autocomplete function for bash
|
__autocomplete__ get autocomplete function for bash
|
||||||
|
|
||||||
@@ -136,6 +157,7 @@ for (( i=1; i<=$#; i++ )); do
|
|||||||
j=$(( i + 1 ))
|
j=$(( i + 1 ))
|
||||||
if [[ "${!i}" = "-m" ]]; then _smenu; exit; fi
|
if [[ "${!i}" = "-m" ]]; then _smenu; exit; fi
|
||||||
if [[ "${!i}" = "-l" ]]; then _menu; exit; fi
|
if [[ "${!i}" = "-l" ]]; then _menu; exit; fi
|
||||||
|
if [[ "${!i}" = "-t" ]]; then _type "${!j}"; exit; fi
|
||||||
if [[ "${!i}" = "-f" ]]; then BAKEFILE="${!j}"; REMOVEARG="${i}"; fi
|
if [[ "${!i}" = "-f" ]]; then BAKEFILE="${!j}"; REMOVEARG="${i}"; fi
|
||||||
if [[ "${!i}" = "-h" ]]; then
|
if [[ "${!i}" = "-h" ]]; then
|
||||||
if [[ -n "${!j}" ]]; then _itemhelp "${!j}"; else _help; fi; exit
|
if [[ -n "${!j}" ]]; then _itemhelp "${!j}"; else _help; fi; exit
|
||||||
|
|||||||
Reference in New Issue
Block a user