git and svn have similar logic right now - they'd be good examples. They default to a Homebrew installation if present, fall back to the system copy otherwise, and error out if neither is present.