Dear GNU lovers,

I'd like to point out an outdated command you placed regarding Homebrew at: https://www.gnu.org/software/emacs/download.html#macos

This pull request (https://github.com/Homebrew/homebrew-core/pull/36070) has removed the --with-cocoa option and the correct command to installing Emacs.app on macOS should be brew cask install emacs. 

For more information, you could refer to this Reddit post: https://www.reddit.com/r/emacs/comments/agvx2m/no_option_withcocoa_in_homebrew_formula_anymore/