PageRenderTime 82ms CodeModel.GetById 60ms app.highlight 1ms RepoModel.GetById 20ms app.codeStats 0ms

/bash_completion.d/ant

http://github.com/brinkman83/bashrc
#! | 74 lines | 68 code | 6 blank | 0 comment | 0 complexity | 30ba3e4d8f9aed078e7d7f4f2ac8706d MD5 | raw file
 1# bash completion for ant
 2
 3have ant && {
 4_ant()
 5{
 6	local cur prev buildfile i
 7
 8	COMPREPLY=()
 9	cur=`_get_cword`
10	prev=${COMP_WORDS[COMP_CWORD-1]}
11
12	case "$prev" in
13		-buildfile|-file|-f)
14			_filedir 'xml'
15			return 0
16			;;
17		-logfile|-l)
18			_filedir
19			return 0
20			;;
21		-propertyfile)
22			_filedir properties
23			return 0
24			;;
25		-nice)
26			COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9 10' \
27				-- "$cur" ) )
28			return 0
29			;;
30		-lib|-logger|-listener|-D|-inputhandler|-main)
31			return 0
32			;;
33	esac
34
35	if [[ "$cur" == -* ]]; then
36		COMPREPLY=( $( compgen -W '-help -h -projecthelp -p -version \
37			-diagnostics -quiet -q -verbose -v -debug -d -emacs -e \
38			-lib -logfile -l -logger -listener -noinput -buildfile \
39			-file -f -D -keep-going -k -propertyfile -inputhandler \
40			-find -s -nice -nouserlib -noclasspath -autoproxy \
41			-main' -- "$cur" ) )
42	else
43		# available targets completion
44		# find which buildfile to use
45		buildfile=build.xml
46		for (( i=1; i < COMP_CWORD; i++ )); do
47			if [[ "${COMP_WORDS[i]}" == -@(?(build)file|f) ]]; then
48				buildfile=${COMP_WORDS[i+1]}
49				break
50			fi
51		done
52		[ ! -f $buildfile ] && return 0
53
54		# parse buildfile for targets
55		# some versions of sed complain if there's no trailing linefeed,
56		# hence the 2>/dev/null
57		COMPREPLY=( $( compgen -W "$( cat $buildfile | \
58			tr "'\t\n>" "\"  \n" | \
59			sed -ne 's/.*<target .*name="\([^"]*\).*/\1/p' \
60			2>/dev/null )" -- "$cur" ) )
61	fi
62}
63have complete-ant-cmd.pl && \
64     complete -C complete-ant-cmd.pl -F _ant $filenames ant || \
65     complete -F _ant $filenames ant
66}
67
68# Local variables:
69# mode: shell-script
70# sh-basic-offset: 4
71# sh-indent-comment: t
72# indent-tabs-mode: nil
73# End:
74# ex: ts=4 sw=4 et filetype=sh