42 lines
1.1 KiB
Bash
Executable File
42 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
list-taskfile-aliases() {
|
|
local bin_dir
|
|
bin_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
for file in "$bin_dir"/*; do
|
|
if [[ -f "$file" ]]; then
|
|
awk '
|
|
/^[a-zA-Z0-9_-]+\(\) \{/ {
|
|
func_name = $0
|
|
sub(/\(\).*/, "", func_name)
|
|
in_func = 1
|
|
body = ""
|
|
next
|
|
}
|
|
in_func && /^\}/ {
|
|
in_func = 0
|
|
if (body ~ /^[ ]*[a-zA-Z0-9_-]+\s+"\$@"[ ]*$/) {
|
|
gsub(/^[ ]+/, "", body)
|
|
gsub(/[ ]+$/, "", body)
|
|
sub(/\s+"\$@"$/, "", body)
|
|
printf "%s='\''%s'\''\n", func_name, body
|
|
}
|
|
next
|
|
}
|
|
in_func {
|
|
if (body == "") {
|
|
body = $0
|
|
} else {
|
|
body = body "\n" $0
|
|
}
|
|
}
|
|
' "$file"
|
|
fi
|
|
done | sort
|
|
}
|
|
|
|
lta() {
|
|
list-taskfile-aliases "$@"
|
|
}
|