Sophie

Sophie

distrib > Mandriva > 2007.1 > x86_64 > by-pkgid > c31e97a8d784100ad4f6db0027d2f7e2 > files > 1

xen-3.0.3-0.20060703.5.1mdv2007.1.src.rpm

# bash completion for xm
# $Id: svk 188 2009-11-26 22:23:28Z guillaume $

_xm()
{
	local cur command options

	COMPREPLY=()
	cur=${COMP_WORDS[COMP_CWORD]}

	commands='console create destroy domid domname list mem-max mem-set \
		migrate pause reboot rename restore save shutdown sysrq top \
		unpause vcpu-list vcpu-pin vcpu-set dmesg info log top \
		sched-bvt sched-bvt-ctxallow sched-sedf block-attach \
		block-detach block-list network-attach network-detach \
		network-list nvet-kist vnet-create vnet-delete help'
	
	if [[ $COMP_CWORD -eq 1 ]] ; then
		COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
	else
		command=${COMP_WORDS[1]}
		if [[ "$cur" == -* ]]; then
			# possible options for the command
			case $command in
				create)
					options='-c'
					;;
				dmesg)
					options='--clear'
					;;
				list)
					options='--long'
					;;
				reboot)
					options='-w -a'
					;;
				shutdown)
					options='-w -a -R -H'
					;;
			esac
			COMPREPLY=( $( compgen -W "$options" -- $cur ) )
		else
			case $command in
				help)
					COMPREPLY=( $(compgen -W "$commands" -- $cur) )
					;;
				@(console|destroy|domnamde|list|mem-@(set|max)|migrate|pause|reboot|rename|save|shutdown|sysrq|unpause|vcpu-@(list|pin|set)|block-@(attach|detach|list)|network-@(attach|detach|list)))
					# complete on dom ID
					COMPREPLY=( $(compgen -W "$( xm list | awk '{ print $1 }' | grep -v -e Name -e Domain-0  )" -- $cur) )
					;;
				create)
					COMPREPLY=( $(compgen -W "$( command ls /etc/xen/*.cfg 2>/dev/null )" -- $cur) )
					;;
			esac
		fi
	fi

	return 0
}
complete -F _xm xm