#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 (f|ht)tp:// ]]; then
	    _urls -f
	else
	    compadd -S '' ftp:// http://
	fi
    else
	false
    fi

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

_scribe "$@"
