#!/bin/zsh

### Print the path of a cloned bundle.
#
# usage: antidote path [-h|--help] <bundle>
#
#function antidote-path {
  emulate -L zsh; setopt local_options $_adote_funcopts

  local o_help
  zparseopts $_adote_zparopt_flags -- h=o_help -help=h || return 1

  if (( $#o_help )); then
    antidote-help path
    return
  fi

  local -a bundles=("${(@f)$(__antidote_collect_input "$@")}")
  if (( $#bundles == 0 )); then
    print -ru2 "antidote: error: required argument 'bundle' not provided, try --help"
    return 1
  fi

  local bundle bundledir
  local -a results=()
  for bundle in $bundles; do
    if [[ $bundle == '$'* ]] && [[ $bundle != *'('* ]] && [[ $bundle != *';'* ]]; then
      bundle=$(eval print $bundle)
    fi
    bundledir=$(__antidote_bundle_dir $bundle)
    if [[ ! -d $bundledir ]]; then
      print -ru2 "antidote: error: $bundle does not exist in cloned paths"
      return 1
    else
      results+=("$bundledir")
    fi
  done
  print -l -- $results
#}
