0
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-09-19 04:01:21 +02:00
ohmyzsh/plugins/grails/grails.plugin.zsh
Josh Soref 0e41181d54
chore: fix spelling errors across the project (#10459)
Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2021-12-01 12:20:31 +01:00

60 lines
1.4 KiB
Bash

_enumerateGrailsScripts() {
# Default directories
directories=($GRAILS_HOME/scripts ~/.grails/scripts ./scripts)
# Check all of the plugins directories, if they exist
if [ -d plugins ]
then
directories+=(plugins/*/scripts)
fi
# Enumerate all of the Groovy files
files=()
for dir in $directories;
do
if [ -d $dir ]
then
files+=($dir/[^_]*.groovy)
fi
done
# Don't try to basename ()
if [ ${#files} -eq 0 ];
then
return
fi
scripts=()
for file in $files
do
# - Strip the path
# - Remove all scripts with a leading '_'
# - PackagePlugin_.groovy -> PackagePlugin
# - PackagePlugin -> Package-Plugin
# - Package-Plugin -> package-plugin
command=$(basename $file \
| sed -E -e 's/^_?([^_]+)_?.groovy/\1/'\
-e 's/([a-z])([A-Z])/\1-\2/g' \
| tr "[:upper:]" "[:lower:]" \
| sort \
| uniq)
scripts+=($command)
done
echo $scripts
}
_grails() {
if (( CURRENT == 2 )); then
scripts=( $(_enumerateGrailsScripts) )
if [ ${#scripts} -ne 0 ];
then
_multi_parts / scripts
return
fi
fi
_files
}
compdef _grails grails