Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/services: support passing multiple formulae #19565

Merged
merged 1 commit into from
Mar 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Library/Homebrew/cmd/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Services < AbstractCommand
switch "--json", description: "Output as JSON."
switch "--no-wait", description: "Don't wait for `stop` to finish stopping the service."
conflicts "--max-wait=", "--no-wait"
named_args max: 2
named_args
end

sig { override.void }
Expand Down Expand Up @@ -93,14 +93,14 @@ def run
end

# Parse arguments.
subcommand, formula, = args.named
subcommand, *formulae = args.named

no_named_formula_commands = [
*Homebrew::Services::Commands::List::TRIGGERS,
*Homebrew::Services::Commands::Cleanup::TRIGGERS,
]
if no_named_formula_commands.include?(subcommand)
raise UsageError, "The `#{subcommand}` subcommand does not accept a formula argument!" if formula
raise UsageError, "The `#{subcommand}` subcommand does not accept a formula argument!" if formulae.present?
raise UsageError, "The `#{subcommand}` subcommand does not accept the --all argument!" if args.all?
end

Expand All @@ -117,7 +117,7 @@ def run
end
end

opoo "The --all argument overrides provided formula argument!" if formula.present? && args.all?
opoo "The --all argument overrides provided formula argument!" if formulae.present? && args.all?

targets = if args.all?
if subcommand == "start"
Expand All @@ -133,8 +133,8 @@ def run
else
Homebrew::Services::Formulae.available_services
end
elsif formula
[Homebrew::Services::FormulaWrapper.new(Formulary.factory(formula))]
elsif formulae.present?
formulae.map { |formula| Homebrew::Services::FormulaWrapper.new(Formulary.factory(formula)) }
else
[]
end
Expand Down
Loading