#!/bin/bash

###########################################################################
#
# MODULE:       Commands
# COPYRIGHT:    (C) 2009-2025 by CacheGuard Technologies Ltd (UK)
# COPYRIGHT:    (C) 2026-2026 by CacheGuard Technologies SAS (FR)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###########################################################################

__complete-vlan()
{
    test -n "${COMP_CWORD-1}" || return 1

    case ${COMP_CWORD} in
	1)
	    case ${COMP_WORDS[1]} in
		a)
		    COMPREPLY=('' admin antivirus)
		    ;;
		ad|ad|adm|admi|admin)
		    COMPREPLY=(admin)
		    ;;
		an|ant|anti|antiv|antivi|antivir|antiviru|antivirus)
		    COMPREPLY=(antivirus)
		    ;;
		p|pe|pee|peer)
		    COMPREPLY=(peer)
		    ;;
		m|mo|mon)
		    COMPREPLY=(mon)
		    ;;
		f|fi|fil|file)
		    COMPREPLY=(file)
		    ;;
		w|we|web)
		    COMPREPLY=(web)
		    ;;
		r|rw|rwe|rweb)
		    COMPREPLY=(rweb)
		    ;;
		e|ex|ext|exte|exter|extern|externa|external)
		    COMPREPLY=(external)
		    ;;
		'')
		    COMPREPLY=('' '<RET>' external admin mon file web rweb antivirus)
		    ;;
	    esac
	    ;;
	2)
	    case ${COMP_WORDS[1]} in
		admin|peer|mon|file|web|rweb|antivirus)
		    COMPREPLY=('' '<RET>' '<vlan-id>')
		    ;;
		external)
		    case ${COMP_WORDS[2]} in
			n|no|non|none)
			    COMPREPLY=(none)
			    ;;
			*)
			    COMPREPLY=('' '<RET>' '<vlan-id>' none)
			    ;;
		    esac
		    ;;
		*)
		    COMPREPLY=()
		    ;;
	    esac
	    ;;
	*)
	    COMPREPLY=()
	    ;;
    esac
}
