Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > 8dc006009caeee49bf7265b32a566d99 > files > 6

xen-3.2.0-6.1mdv2008.1.i586.rpm

# bash completion for xm
# $Id: xen 444 2008-03-22 14:23:10Z guillomovitch $

_xm()
{
	local cur prev command options

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

	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)
					_filedir
					COMPREPLY=( ${COMPREPLY[@]:-} \
						$( command ls /etc/xen | grep "^$cur" ) )
					;;
			esac
		fi
	fi

	return 0
}
complete -F _xm xm