#!/bin/sh -e

set -u

usage() {
  printf %s "\
comparing dirs: $(basename "$0") <dir_a> <dir_b>
comparing files: $(basename "$0") <file_a> <file_b>
"
  exit 1
}

if [ "$#" -ne 2 ]; then
  printf '%s\n' "$(basename "$0") requires two arguments"
  usage
fi

left="${1}"
right="${2}"

if [ -d "${left}" ] && [ -d "${right}" ]; then
  ${EDITOR:-vi} +"DirDiff ${left} ${right}"
else
  ${EDITOR:-vi} -d "${left}" "${right}"
fi
