#compdef scribe

_scribe () {
    
    _arguments -s \
    '*::scribe command:_scribe_command'

}

# Define scribe command dispatch function.
(( $+functions[_scribe_command] )) ||
_scribe_command () {
    	    
  # complete command
  if (( CURRENT == 1 )); then
    _tags comands && {compadd add remove update fix }

  # complete commands argument
  elif (( CURRENT == 2 )); then
    true
    
  # this is not implemented correctly.
  elif (( CURRENT == 3 )); then
    compadd from
    
  elif (( CURRENT == 4 )); then
    if [[ "${words[3]}" == from ]]; then
	if [[ -prefix 1 (svn|svn_ssh|file|dir|cvs|rsync|smgl_tla|svn_http|svn_https|git|git_http|git_local|ftp|http|hg_http):// ]]; then
	    _urls -f
	else
	    compadd -S '' ftp:// http:// svn:// svn_ssh:// file:// dir:// cvs:// rsync:// smgl_tla:// svn_http:// svn_https:// git:// git_http:// git_local:// hg_http://
	fi
    else
	false
    fi

  # then scribe dosen't take more args.
  else
    false
  fi
}

_scribe "$@"
