2019-01-03 22:03:22 +08:00
|
|
|
# Apache Ant (1.9.5) completion for Fish Shell.
|
2006-12-06 07:52:52 +08:00
|
|
|
|
2019-11-27 21:35:04 +08:00
|
|
|
function __fish_complete_ant_targets -d "Print list of targets from build.xml and imported files"
|
|
|
|
function __get_buildfile -d "Get a buildfile that will be used by ant"
|
2024-01-22 14:42:45 +08:00
|
|
|
set -l tokens $argv # tokens from 'commandline -xpc'
|
2019-11-27 21:35:04 +08:00
|
|
|
set -l prev $tokens[1]
|
|
|
|
set -l buildfile "build.xml"
|
|
|
|
for token in $argv[2..-1]
|
|
|
|
switch $prev
|
|
|
|
case -buildfile -file -f
|
2024-01-06 15:45:33 +08:00
|
|
|
set buildfile echo $token
|
2019-11-27 21:35:04 +08:00
|
|
|
end
|
|
|
|
set prev $token
|
|
|
|
end
|
|
|
|
# return last one
|
|
|
|
echo $buildfile
|
|
|
|
end
|
|
|
|
function __parse_ant_targets_from_projecthelp -d "Parse ant targets from projecthelp"
|
|
|
|
set -l buildfile $argv[1] # full path to buildfile
|
|
|
|
set -l targets (ant -p -debug -f $buildfile 2> /dev/null | string match -r '^\s[[:graph:]].*$')
|
|
|
|
for target in $targets
|
|
|
|
# Use [[:graph:]] and [[:print:]] to ignore ANSI escape code
|
|
|
|
set -l tokens (string match -r '^\s([[:graph:]]+)(?:\s+([[:print:]]+))?' "$target")
|
2021-11-23 21:45:28 +08:00
|
|
|
if test (count $tokens) -ge 3
|
2019-11-27 21:35:04 +08:00
|
|
|
echo $tokens[2]\t$tokens[3]
|
2021-11-23 21:45:28 +08:00
|
|
|
else if test (count $tokens) -ge 2
|
2019-11-27 21:35:04 +08:00
|
|
|
echo $tokens[2]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function __get_ant_targets_from_projecthelp -d "Get ant targets from projecthelp"
|
|
|
|
set -l buildfile $argv[1] # full path to buildfile
|
|
|
|
|
2020-05-20 02:41:47 +08:00
|
|
|
set -l xdg_cache_home $XDG_CACHE_HOME[1]
|
2021-10-15 01:25:23 +08:00
|
|
|
if test -z "$xdg_cache_home"
|
2020-05-15 13:56:06 +08:00
|
|
|
set xdg_cache_home $HOME/.cache
|
2019-11-27 21:35:04 +08:00
|
|
|
end
|
|
|
|
|
2020-05-15 13:56:06 +08:00
|
|
|
set -l cache_dir $xdg_cache_home/fish/ant_completions
|
2019-11-27 21:35:04 +08:00
|
|
|
mkdir -p $cache_dir
|
|
|
|
|
2020-03-02 00:22:10 +08:00
|
|
|
set -l cache_file $cache_dir/(__fish_md5 -s $buildfile)
|
2021-11-23 21:45:28 +08:00
|
|
|
if test ! -s "$cache_file"
|
2019-11-27 21:35:04 +08:00
|
|
|
# generate cache file if empty
|
|
|
|
__parse_ant_targets_from_projecthelp $buildfile >$cache_file
|
|
|
|
end
|
|
|
|
|
|
|
|
cat $cache_file
|
|
|
|
end
|
|
|
|
|
|
|
|
set -l tokens $argv
|
2022-08-26 01:00:29 +08:00
|
|
|
set -l buildfile (__get_buildfile $tokens | path filter)
|
|
|
|
or return 1 # return nothing if buildfile does not exist
|
2019-11-27 21:35:04 +08:00
|
|
|
|
|
|
|
__get_ant_targets_from_projecthelp $buildfile
|
|
|
|
end
|
|
|
|
|
2019-01-03 22:03:22 +08:00
|
|
|
# completion for ant targets
|
2024-01-22 14:42:45 +08:00
|
|
|
complete -x -c ant -a "(__fish_complete_ant_targets (commandline -xpc))"
|
2006-12-06 07:52:52 +08:00
|
|
|
|
2019-01-03 22:03:22 +08:00
|
|
|
# Script Options:
|
|
|
|
complete -f -c ant -l help -l h -d 'print help message and ant help'
|
2022-01-20 07:06:13 +08:00
|
|
|
complete -f -c ant -l noconfig -d 'suppress sourcing of configuration files'
|
|
|
|
complete -f -c ant -l usejikes -d 'enable use of jikes by default'
|
2019-01-03 22:03:22 +08:00
|
|
|
complete -f -c ant -l execdebug -d 'print ant exec line generated by this launch script'
|
|
|
|
# Options:
|
2022-01-20 07:06:13 +08:00
|
|
|
complete -f -c ant -o help -s h -d 'print help message'
|
|
|
|
complete -f -c ant -o projecthelp -s p -d 'print project help information'
|
|
|
|
complete -f -c ant -o version -d 'print the version information'
|
|
|
|
complete -f -c ant -o diagnostics -d 'print diagnostic information'
|
2019-01-03 22:03:22 +08:00
|
|
|
complete -f -c ant -o quiet -s q -d 'be extra quiet'
|
|
|
|
complete -f -c ant -o silent -s S -d 'print nothing but task outputs and build failures'
|
|
|
|
complete -f -c ant -o verbose -s v -d 'be extra verbose'
|
|
|
|
complete -f -c ant -o debug -s d -d 'print debugging information'
|
|
|
|
complete -f -c ant -o emacs -s e -d 'produce logging information without adornments'
|
|
|
|
complete -f -c ant -o noinput -d 'do not allow interactive input'
|
|
|
|
complete -f -c ant -s D -d 'use value for given property like -D<property>=<value>'
|
|
|
|
complete -f -c ant -o keep-going -s k -d 'execute all targets that do not depend on failed target(s)'
|
2022-01-20 07:06:13 +08:00
|
|
|
complete -f -c ant -o nouserlib -d 'Run ant without using jar files from ${user.home}/.ant/lib'
|
2019-01-03 22:03:22 +08:00
|
|
|
complete -f -c ant -o noclasspath -d 'Run ant without using CLASSPATH'
|
|
|
|
complete -f -c ant -o autoproxy -d 'Java1.5+: use the OS proxy settings'
|
|
|
|
complete -r -c ant -o lib -d 'specifies a path to search for jars and classes'
|
|
|
|
complete -r -c ant -o logfile -s l -d 'use given file for log'
|
|
|
|
complete -r -c ant -o logger -d 'the class which is to perform logging'
|
|
|
|
complete -r -c ant -o listener -d 'add an instance of class as a project listener'
|
|
|
|
complete -r -c ant -o buildfile -o file -s f -d 'use given buildfile'
|
2022-01-20 07:06:13 +08:00
|
|
|
complete -r -c ant -o propertyfile -d 'load properties from file, -D properties takes precedence'
|
2019-01-03 22:03:22 +08:00
|
|
|
complete -r -c ant -o inputhandler -d 'the class which will handle input requests'
|
2022-01-20 07:06:13 +08:00
|
|
|
complete -r -c ant -o find -s s -d 'search for buildfile towards the root and use it'
|
|
|
|
complete -r -c ant -o nice -d 'A niceness value for the main thread'
|
2019-01-03 22:03:22 +08:00
|
|
|
complete -r -c ant -o main -d 'override Ant\'s normal entry point'
|