# -*- Mode: sh; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2009 Didier Roche
#
# This file is part of Quickly
#
#This program is free software: you can redistribute it and/or modify it
#under the terms of the GNU General Public License version 3, as published
#by the Free Software Foundation.
#
#This program is distributed in the hope that it will be useful, but
#WITHOUT ANY WARRANTY; without even the implied warranties of
#MERCHANTABILITY, SATISFACTORY QUALITY, 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/>.
#

_quickly_call()
{
    # if current is empty, give it empty to quickly shell parser
    if [ -z "${COMP_WORDS[COMP_CWORD]}" ] ; then
        echo $(quickly shell-completion $* '')
    else
        echo $(quickly shell-completion $*)
    fi
}

_quickly()
{
    cur=${COMP_WORDS[COMP_CWORD]}
    #prev=${COMP_WORDS[COMP_CWORD-1]}
    #echo "$(_quickly_call ${COMP_WORDS[*]})"a
    #echo "current: "$cur
    COMPREPLY=( $( compgen -W "$(_quickly_call ${COMP_WORDS[*]})" -- $cur ) )

    return 0
}
complete -F _quickly -o default quickly

