_sdk()
{
	local cur prev opts
	COMPREPLY=()
	cur="${COMP_WORDS[COMP_CWORD]}"
	prev="${COMP_WORDS[COMP_CWORD-1]}"

	case "$prev" in
	cd|init)
		local projects=$(sdk valid_projects)
		COMPREPLY=($(compgen -W "$projects" -- $cur))
		return 0
		;;
	build)
		local projects=$(sdk valid_build_targets)
		COMPREPLY=($(compgen -W "$projects" -- $cur))
		return 0
		;;
	edit)
		local targets=$(sdk valid_edit_targets)
		COMPREPLY=($(compgen -W "$targets" -- $cur))
		return 0
		;;
	reload)
		local reload_opts="--experimental --system"
		COMPREPLY=($(compgen -W "$reload_opts" -- $cur))
		return 0
		;;
	create-desktop-icon)
		return 1
		;;
	esac

	opts=$(sdk valid_commands)
	COMPREPLY=($(compgen -W "$opts" -- $cur))
	   return 0
}
complete -F _sdk sdk
