Skip to content

Commit 85aa028

Browse files
authored
Merge pull request #19565 from Homebrew/services-multi-arg
cmd/services: support passing multiple formulae
2 parents 37af9b6 + 72d4767 commit 85aa028

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Library/Homebrew/cmd/services.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Services < AbstractCommand
5858
switch "--json", description: "Output as JSON."
5959
switch "--no-wait", description: "Don't wait for `stop` to finish stopping the service."
6060
conflicts "--max-wait=", "--no-wait"
61-
named_args max: 2
61+
named_args
6262
end
6363

6464
sig { override.void }
@@ -93,14 +93,14 @@ def run
9393
end
9494

9595
# Parse arguments.
96-
subcommand, formula, = args.named
96+
subcommand, *formulae = args.named
9797

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

@@ -117,7 +117,7 @@ def run
117117
end
118118
end
119119

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

122122
targets = if args.all?
123123
if subcommand == "start"
@@ -133,8 +133,8 @@ def run
133133
else
134134
Homebrew::Services::Formulae.available_services
135135
end
136-
elsif formula
137-
[Homebrew::Services::FormulaWrapper.new(Formulary.factory(formula))]
136+
elsif formulae.present?
137+
formulae.map { |formula| Homebrew::Services::FormulaWrapper.new(Formulary.factory(formula)) }
138138
else
139139
[]
140140
end

0 commit comments

Comments
 (0)