summaryrefslogtreecommitdiffstats
path: root/scripts/bash_completion
blob: f24672fcaa5885f272e8a86f6c28e02d67789912 (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
56
57
58
59
60
61
62
#!/bin/bash
#
# bash_completion for PTXdist by Wolfram Sang, Pengutronix e.K., in 2008-2010
# part of PTXdist, so same licence.
#

if have ptxdist; then

_ptxdist_completion()
{
	local cur cmds opts

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

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

	# if no commands were given, complete on commands themselves
	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 /dummy >/dev/null
		[ $COMP_CWORD -lt 4 ] && _filedir -d
		;;
	toolchain|export_src)
		compgen -f /dummy >/dev/null
		[ $COMP_CWORD -lt 3 ] && _filedir -d
		;;
	select|platform|collection)
		compgen -f /dummy >/dev/null
		[ $COMP_CWORD -lt 3 ] && _filedir
		;;
	get|extract|prepare|compile|install|targetinstall|tags)
		COMPREPLY=( $( compgen -W "${opts} $( ptxdist print PTX_PACKAGES_SELECTED )" -- $cur ) )
		;;
	clean)
		COMPREPLY=( $( compgen -W "${opts} $( ptxdist print PTX_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 ) )
		;;
	newpackage)
		COMPREPLY=( $( compgen -W "${opts} target host cross klibc arc-autoconf-lib src-autoconf-prog src-autoconf-proglib src-cmake-prog src-linux-dirver src-make-prog src-stellaris font simple" -- $cur) )
		;;
	esac
	return 0
}

complete -F _ptxdist_completion ptxdist

fi