summaryrefslogtreecommitdiffstats
path: root/scripts/bash_completion
blob: 47812b98f1793d3fd2ea63bacaf3b9260dde8654 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# bash_completion for PTXdist by Wolfram Sang, Pengutronix e.K., in 2008
# part of PTXdist, so same licence.

if have ptxdist; then

_ptxdist_completion()
{
	local cur cmds opts

	COMPREPLY=()
	cur=( $(_get_cword) )

	opts=' --debug --force --j-extern --j-intern --platformconfig --ptxconfig --quiet --toolchain'
	cmds=' autobuild boardsetup clean clone compile distclean drop export_src extract get go images install kernelconfig menu menuconfig newpacket oldconfig platform platformconfig prepare print projects ptxdist select setup tags targetinstall test toolchain u_boot_config version'

	# if no command were given, complete on commands
	if [ $COMP_CWORD -eq 1 ]; then
		COMPREPLY=( $( compgen -W "${cmds} help" -- $cur ) )
		return 0
	fi

	# Complete depending on options
	case ${COMP_WORDS[1]} in
	menuconfig)
		COMPREPLY=( $( compgen -W "${opts} kernel platform u-boot-v2" -- $cur) )
		;;
	clone)
		#HACK! Enable filename completion without specifying '-o filenames' during complete (that will add slashes to commands if there is a dir of the same name :( )
		compgen -f >/dev/null
		[ $COMP_CWORD -lt 4 ] && _filedir -d
		;;
	select|platform|toolchain|export_src)
		compgen -f >/dev/null
		[ $COMP_CWORD -lt 3 ] && _filedir -d
		;;
	get|extract|prepare|compile|install|targetinstall|tags)
		COMPREPLY=( $( compgen -W "${opts} $( ptxdist print PACKAGES_SELECTED )" -- $cur ) )
		;;
	clean)
		COMPREPLY=( $( compgen -W "${opts} $( ptxdist print PACKAGES_SELECTED ) root" -- $cur ) )
		;;
	drop)
		COMPREPLY=( $( compgen -W "${opts} $( pushd $(ptxdist print PTXDIST_PLATFORMDIR)/state >/dev/null; ls +(*.get|*.extract|*.prepare|*.compile|*.install|*.targetinstall); popd >/dev/null )" -- $cur ) )
		;;
	newpacket)
		COMPREPLY=( $( compgen -W "${opts} target host host-existing-target cross cross-existing-target source kernel-driver font simple" -- $cur) )
		;;
	esac
	return 0
}

complete -F _ptxdist_completion ptxdist

fi