source /usr/lib/l3vm/l3vm_config_lib.sh

BACKUP_OPTIONS="-a --all -b --backup-dir -l --list -m --modified -s --supported -h --help"
RESTORE_OPTIONS="-b --backup-dir -m --mac -n --name -h --help"

_l3vm_template_backup() {
    if [ "${#COMP_WORDS[@]}" -le 2 ] || [ "$COMP_CWORD" = 1 ]; then
        COMPREPLY=( $(compgen -W "backup restore -h --help help" -- "${COMP_WORDS[COMP_CWORD]}") )
        return
    fi
    case "${COMP_WORDS[1]}" in
        backup)
           COMPREPLY=( $(compgen -W "${BACKUP_OPTIONS} ${L3VM_TEMPLATES[@]}" -- "${COMP_WORDS[COMP_CWORD]}") )
        ;;
        restore)
            COMPREPLY=( $(compgen -W "${RESTORE_OPTIONS}" -- "${COMP_WORDS[COMP_CWORD]}") )

    esac


}

complete -F _l3vm_template_backup l3vm_template_backup
