#!/bin/bash

_hostos-upgrade()
{
	COMPREPLY=()
	local cur=${COMP_WORDS[COMP_CWORD]};
	local cmd=${COMP_WORDS[COMP_CWORD-1]};	
	case $cmd in
		-path)
			compopt -o nospace
			local len=$((${#cur}-1))
			if [[ "${cur:${len}:1}" != "/" && -d "${cur}" ]];then
				cur="${cur}/"
			fi
			COMPREPLY=( $(compgen -o "default" -o "dirnames" -- $cur) );;
		--setrebootsym)
			COMPREPLY=( $(compgen -W "yes no" -- $cur) );;
		--print)
			COMPREPLY=( $(compgen -W "1" -- $cur) );;
		--check|--dispatch|--install)
			COMPREPLY=( $(compgen -W "-path" -- $cur) );;
		-h|--help)
			;;
		build_upgrade|*)
			COMPREPLY=($(compgen -W "-h --help -path --dispatch --check --install --rollback --commit --needreboot --setrebootsym --sysenhance --print" -- $cur))
			;;
	esac
	return 0
}

complete -F _hostos-upgrade hostos-upgrade
