14 Commits

Author SHA1 Message Date
Mike McQuaid
a1f112f3fe
Move o* output methods to Utils::Output
This reduces the surface area of our `Kernel` monkeypatch and removes
the need to `include Kernel` in a bunch of modules.

While we're here, also move `Kernel#require?` to `Homebrew` and fully
scope the calls to it.
2025-08-20 19:20:19 +01:00
Mike McQuaid
1d482244e5
service: ensure JSON cron output can be null.
This better matches other field and existing behaviour.
2025-08-06 16:09:39 +01:00
Bo Anderson
ae58b3ef21
services: try multiple domains when stopping 2025-05-02 06:19:53 +01:00
Bo Anderson
52a7b67ba5
Revert "Revert "services: add loaded_file data""
This reverts commit 76901b1352d776a0fb53696b0e61eed420186b0c.
2025-04-07 14:05:39 +01:00
Mike McQuaid
76901b1352
Revert "services: add loaded_file data" 2025-04-04 13:11:13 +01:00
Bo Anderson
a6bee0736f
services: add loaded_file data 2025-04-04 07:25:10 +01:00
Mike McQuaid
c592ae63dd
services: prioritise launchctl print over launchctl list.
In https://github.com/Homebrew/brew/pull/19602 we changed
`launchctl list` to pass the domain target. Sadly, this is not valid
syntax. Instead, restore passing the `service_name` to `launchctl list`
and instead use `launchctl print` first to query the more specific
domain target before we fall back to the less specific service name.
2025-04-03 10:01:45 +01:00
Bo Anderson
615fb764a1
Add brew bundle services helper 2025-03-28 05:21:07 +00:00
Mike McQuaid
2dcd8846a3
services: use domain target in launchctl list command.
If a service is somehow duplicated across multiple domains, this ensures
that the correct output is produced.
2025-03-25 14:16:29 +00:00
Jim Myhrberg
f969c05b20
fix(services/list): correctly handle services with an error code
The `brew services list` command was not correctly handling services
that had an error code status.

While the `#zero?` method returns a boolean, the `#nonzero?` method
confusingly returns self or nil. Hence a negated `#zero?` call to check
for a non-zero exit code fixes the error.

While here, `#pid?` method uses a negated `#zero?`, which is not
accurate, as a negative PID value would not be a valid PID. Hence I
changed it to use `#positive?` instead.

The tests for the `#error?` method were marked as needing systemd, but I
saw no obvious reason for that due to how they all use mocked values, so
I removed the systemd requirement.
2025-03-15 22:13:44 +00:00
Mike McQuaid
c82518032e
Fix services types
Some of the typing/`T.must` usage when moving the
Homebrew/homebrew-services code to Homebrew/brew was not quite correct.

Rather than trying to make everything `strict` and import at the same
time: let's mostly loosen the typing to fix a few bugs and allow us to
add more later.
2025-03-14 16:53:07 +00:00
Bo Anderson
02cd7a63c8
Move Services module to Homebrew namespace 2025-03-14 08:19:11 +00:00
botantony
25b9000c77
spec_helper: add :needs_systemd
Signed-off-by: botantony <antonsm21@gmail.com>
2025-03-13 20:29:26 +01:00
Mike McQuaid
084ddca27a
Cleanup and fix homebrew-services migration 2025-03-13 15:22:01 +00:00