# shellcheck shell=bash
#########################################################################
#									#
# Author: Copyright (C) 2025, 2026  Mark Grant				#
#									#
# Released under the GPLv3 only.					#
# SPDX-License-Identifier: GPL-3.0-only					#
#									#
# Purpose:								#
# Bash completion script.						#
#									#
#########################################################################


_lqvms_snap()
{
	local cur prev OPTS

	COMPREPLY=()
	cur="${COMP_WORDS[COMP_CWORD]}"
	prev="${COMP_WORDS[COMP_CWORD-1]}"
	# The connection URI can contain colons. Treat colon as part of word,
	# not as word break.
	_init_completion -n : cur
	case $prev in
	-u|--connect-uri)
		OPTS="qemu:///session qemu:///system"
		# shellcheck disable=SC2207  # This is _the_ bash
		# completion pattern, so leave it be.
		COMPREPLY=( $(compgen -W "${OPTS[*]}" -- "$cur") )
		__ltrim_colon_completions "$cur"
		return 0
		;;
	esac
	OPTS="-a -h -t -u -V"
	OPTS+=" --connect-uri --delete-all --delete-to-current --help --version"
	# shellcheck disable=SC2207  # This is _the_ bash # completion pattern,
	# so leave it be.
	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- "$cur") )
	return 0
}
complete -F _lqvms_snap lqvms-snap

