fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes AltmanningerMerge changes to config paths6d0cd3d9b

master
4.1 KiB84 linesraw
1# Apache Ant (1.9.5) completion for Fish Shell.
2
3function __fish_complete_ant_targets -d "Print list of targets from build.xml and imported files"
4    function __get_buildfile -d "Get a buildfile that will be used by ant"
5        set -l tokens $argv # tokens from 'commandline -xpc'
6        set -l prev $tokens[1]
7        set -l buildfile "build.xml"
8        for token in $argv[2..-1]
9            switch $prev
10                case -buildfile -file -f
11                    set buildfile echo $token
12            end
13            set prev $token
14        end
15        # return last one
16        echo $buildfile
17    end
18    function __parse_ant_targets_from_projecthelp -d "Parse ant targets from projecthelp"
19        set -l buildfile $argv[1] # full path to buildfile
20        set -l targets (ant -p -debug -f $buildfile 2> /dev/null | string match -r '^\s[[:graph:]].*$')
21        for target in $targets
22            # Use [[:graph:]] and [[:print:]] to ignore ANSI escape code
23            set -l tokens (string match -r '^\s([[:graph:]]+)(?:\s+([[:print:]]+))?' "$target")
24            if test (count $tokens) -ge 3
25                echo $tokens[2]\t$tokens[3]
26            else if test (count $tokens) -ge 2
27                echo $tokens[2]
28            end
29        end
30    end
31    function __get_ant_targets_from_projecthelp -d "Get ant targets from projecthelp"
32        set -l buildfile $argv[1] # full path to buildfile
33
34        set -l cache_dir (__fish_make_cache_dir ant_completions)
35        set -l cache_file $cache_dir/(__fish_md5 -s $buildfile)
36        if test ! -s "$cache_file"
37            # generate cache file if empty
38            __parse_ant_targets_from_projecthelp $buildfile >$cache_file
39        end
40
41        cat $cache_file
42    end
43
44    set -l tokens $argv
45    set -l buildfile (__get_buildfile $tokens | path filter)
46    or return 1 # return nothing if buildfile does not exist
47
48    __get_ant_targets_from_projecthelp $buildfile
49end
50
51# completion for ant targets
52complete -x -c ant -a "(__fish_complete_ant_targets (commandline -xpc))"
53
54# Script Options:
55complete -f -c ant -l help -l h -d 'print help message and ant help'
56complete -f -c ant -l noconfig -d 'suppress sourcing of configuration files'
57complete -f -c ant -l usejikes -d 'enable use of jikes by default'
58complete -f -c ant -l execdebug -d 'print ant exec line generated by this launch script'
59# Options:
60complete -f -c ant -o help -s h -d 'print help message'
61complete -f -c ant -o projecthelp -s p -d 'print project help information'
62complete -f -c ant -o version -d 'print the version information'
63complete -f -c ant -o diagnostics -d 'print diagnostic information'
64complete -f -c ant -o quiet -s q -d 'be extra quiet'
65complete -f -c ant -o silent -s S -d 'print nothing but task outputs and build failures'
66complete -f -c ant -o verbose -s v -d 'be extra verbose'
67complete -f -c ant -o debug -s d -d 'print debugging information'
68complete -f -c ant -o emacs -s e -d 'produce logging information without adornments'
69complete -f -c ant -o noinput -d 'do not allow interactive input'
70complete -f -c ant -s D -d 'use value for given property like -D<property>=<value>'
71complete -f -c ant -o keep-going -s k -d 'execute all targets that do not depend on failed target(s)'
72complete -f -c ant -o nouserlib -d 'Run ant without using jar files from ${user.home}/.ant/lib'
73complete -f -c ant -o noclasspath -d 'Run ant without using CLASSPATH'
74complete -f -c ant -o autoproxy -d 'Java1.5+: use the OS proxy settings'
75complete -r -c ant -o lib -d 'specifies a path to search for jars and classes'
76complete -r -c ant -o logfile -s l -d 'use given file for log'
77complete -r -c ant -o logger -d 'the class which is to perform logging'
78complete -r -c ant -o listener -d 'add an instance of class as a project listener'
79complete -r -c ant -o buildfile -o file -s f -d 'use given buildfile'
80complete -r -c ant -o propertyfile -d 'load properties from file, -D properties takes precedence'
81complete -r -c ant -o inputhandler -d 'the class which will handle input requests'
82complete -r -c ant -o find -s s -d 'search for buildfile towards the root and use it'
83complete -r -c ant -o nice -d 'A niceness value for the main thread'
84complete -r -c ant -o main -d 'override Ant\'s normal entry point'