Simplify code by using `Pathname` methods as much as possible. Also
avoid calling external commands for basic functionality like symlink
creation, refactor code that can be shared with `brew unlinkapps`, and
print a summary line at the end (if symlinks were created).
`Keg#app_installed?` only checks the formula prefix and `libexec/` for
.app bundles to determine if a formula provides any. This is used by
`Caveats#app_caveats` to generate an appropriate message. The same list
should be used by `brew linkapps` for consistency.
Reduce likelihood of future inconsistencies by creating `Keg#apps` and
using it in place of the duplicate code.
ClosesHomebrew/homebrew#45173.
Signed-off-by: Xu Cheng <xucheng@me.com>
The standard message can be somewhat confusing (#38695) in that it
outputs “finished linking” language regardless of whether an app is
actually present/linked or not.
This solution just stops it saying anything if there’s no app in the
directory. It needs a little tidying in the output here, but it’s a
discussion point.
ClosesHomebrew/homebrew#38728.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>