#!/bin/bash




_voxl_focus_camera(){


	local OPTS=('--en_debug --extrinsics-only --fisheye --skip_extrinsics --help --length --mirror --no-targets --no-threshold --size --thermal')


	# generate list of cams
	CAMS=()
	for fileName in /run/mpa/*; do
		if [ -f ${fileName}/info ]; then
			if cat ${fileName}/info | grep -q "camera_image_metadata_t" && \
			   ! cat ${fileName}/info | grep -q "tof" && \
			   ! [[ "$(basename ${fileName})" == *"overlay"* ]]; then
				CAMS+=("$(basename $fileName)")
			fi
		fi
	done
	COMPLETE_LIST=("${CAMS[@]}" "${OPTS[@]}")


	COMPREPLY=()

	# case for first argument
	if [ "$COMP_CWORD" -eq 1 ]; then
		COMPREPLY=( $(compgen -W '${CAMS[@]}' -- ${COMP_WORDS[COMP_CWORD]}) )
		return 0
	fi

	# case for when at least one argument has already been provided
	case ${COMP_WORDS[COMP_CWORD-1]} in
		-*)
			COMPREPLY=( $(compgen -W '${CAMS[@]}' -- ${COMP_WORDS[COMP_CWORD]}) )
			return 0
			;;

		*)
			COMPREPLY=( $(compgen -W '${OPTS[@]}' -- ${COMP_WORDS[COMP_CWORD]}) )
			return 0
			;;
	esac
	return 0

}

complete -F _voxl_focus_camera voxl-focus-camera
