#autoload

# cast --from
# summon --from

if [[ ${words[$(( $CURRENT-1 ))]} == --from ]]; then
    _files
else
    # define SGL_LIBRARY
    for i in `seq $CURRENT`; do
	if [[ ${words[$i]} == --from ]]; then
	    _SGL_LIBRARY=${words[$(( $i + 1 ))]}
        fi
    done

    # define $GRIMOIRE_DIR
    # GRIMOIRE_DIR must contains "GRIMOIRE" file.
    typeset -A GRIMOIRE_DIR
    GRIMOIRE_DIR=(
	$( /bin/ls $_SGL_LIBRARY/codex/*/GRIMOIRE |sed 's/\/GRIMOIRE//' )
    )

    # call _spells to compadd
    _spells

    # finalization
    typeset GRIMOIRE_DIR=""
fi
