mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Gradle-completions for gradle tasks (#3972)
* Implement https://github.com/hanny24/gradle-fish/blob/master/gradle.load * Use XDG_CACHE_HOME * Use __funced_md5 * Fix fish_md5.fish * Actually use the new function. * Use string match for matching tasks * I goofed. Actually pass a string to complete -a * Fix attempt to remove needed function... * Fix regex * Fix fish_md5.fish to use a flag
This commit is contained in:
parent
9e64571de0
commit
573c539956
2 changed files with 50 additions and 0 deletions
|
@ -37,3 +37,25 @@ complete -c gradle -l continuous -s t -d 'Enable continuous build'
|
||||||
complete -c gradle -l no-search-upward -s u -d 'Don\'t search in parent folders for settings file'
|
complete -c gradle -l no-search-upward -s u -d 'Don\'t search in parent folders for settings file'
|
||||||
complete -c gradle -l version -s v -d 'Print version'
|
complete -c gradle -l version -s v -d 'Print version'
|
||||||
complete -c gradle -l exclude-task -s x -x -d 'Specify task to be excluded from execution'
|
complete -c gradle -l exclude-task -s x -x -d 'Specify task to be excluded from execution'
|
||||||
|
|
||||||
|
# https://github.com/hanny24/gradle-fish/blob/master/gradle.load
|
||||||
|
function __cache_or_get_gradle_completion
|
||||||
|
# Set up cache directory
|
||||||
|
if test -z $XDG_CACHE_HOME
|
||||||
|
set XDG_CACHE_HOME $HOME/.cache/
|
||||||
|
end
|
||||||
|
mkdir -m 700 -p $XDG_CACHE_HOME/gradle-completions
|
||||||
|
|
||||||
|
set -l hashed_pwd (fish_md5 -s $PWD)
|
||||||
|
set -l gradle_cache_file $XDG_CACHE_HOME/gradle-completions/$hashed_pwd
|
||||||
|
if not test -f $gradle_cache_file; or command test build.gradle -nt $gradle_cache_file
|
||||||
|
command gradle -q tasks ^/dev/null | string match -r '^[[:alnum:]]+ - .*' | string replace ' - ' \t > $gradle_cache_file
|
||||||
|
end
|
||||||
|
cat $gradle_cache_file
|
||||||
|
end
|
||||||
|
|
||||||
|
function __contains_gradle_build
|
||||||
|
test -f build.gradle
|
||||||
|
end
|
||||||
|
|
||||||
|
complete -x -c gradle -n '__contains_gradle_build' -a "(__cache_or_get_gradle_completion)"
|
||||||
|
|
28
share/functions/fish_md5.fish
Normal file
28
share/functions/fish_md5.fish
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
function fish_md5
|
||||||
|
if type -q md5sum
|
||||||
|
# GNU systems
|
||||||
|
if set -q argv[2]
|
||||||
|
if test $argv[1] = "-s"
|
||||||
|
echo (echo $argv[2] | md5sum | string split ' ')[1]
|
||||||
|
else
|
||||||
|
printf (_ "%s: Too many arguments %s\n") fish_md5 $argv
|
||||||
|
end
|
||||||
|
else
|
||||||
|
echo (md5sum $argv[1] | string split ' ')[1]
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
else if type -q md5
|
||||||
|
# BSD systems
|
||||||
|
if set -q argv[2]
|
||||||
|
if test $argv[1] = "-s"
|
||||||
|
md5 -s $argv[1]
|
||||||
|
else
|
||||||
|
printf (_ "%s: Too many arguments %s\n") fish_md5 $argv
|
||||||
|
end
|
||||||
|
else
|
||||||
|
md5 -q $argv[1]
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return 1
|
||||||
|
end
|
Loading…
Reference in a new issue