fix Formula dependencies by invoking Homebrew CLI

According to the logic of #5080, we should move away from calling
Homebrew internals, in part because things break over time, as
happened here with the implementation of `depends_on_formula`
(shortly to become `depends_on :formula`).

This re-implements formula dependencies by invoking the Homebrew
CLI, which is the only stable API Homebrew guarantees.

Fixes #5475
Fixes #4010
Merge pull request #5590 from rolandwalker/depends_on_via_cli

fix Formula dependencies by invoking Homebrew CLI