_storage()
{
    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD-1]}
    options=
    if [[ "$COMP_CWORD" == 1 ]];
    then
        options='ahash librarian bartender shepherd';
    else
        case $prev in
            hash)
                options='get change changeIf'
                ;;
            librarian)
                options='get traverseLN new modifyMetadata remove'
                ;;
            bartender)
                options='stat makeCollection list move putFile getFile delFile addReplica modify'
                ;;
            shepherd)
                options='get put stat reporting'
                ;;
        esac
    fi
    if [[ "-$options" == "-" ]];
    then
        case $prev in
            putFile)
                COMPREPLY=( $( compgen -o default -- $cur) ) 
                ;;
            getFile)
                COMPREPLY=( $( compgen -o default -- $cur) ) 
                ;;
            addReplica)
                COMPREPLY=( $( compgen -o default -- $cur) ) 
                ;;
        esac
    else
        COMPREPLY=( $( compgen -W "$options" -- $cur) )
    fi
}
complete -F _storage storage
