cmd/services: support passing multiple formulae
This commit is contained in:
parent
75de3aaeb5
commit
72d47678c7
@ -58,7 +58,7 @@ module Homebrew
|
|||||||
switch "--json", description: "Output as JSON."
|
switch "--json", description: "Output as JSON."
|
||||||
switch "--no-wait", description: "Don't wait for `stop` to finish stopping the service."
|
switch "--no-wait", description: "Don't wait for `stop` to finish stopping the service."
|
||||||
conflicts "--max-wait=", "--no-wait"
|
conflicts "--max-wait=", "--no-wait"
|
||||||
named_args max: 2
|
named_args
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { override.void }
|
sig { override.void }
|
||||||
@ -93,14 +93,14 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Parse arguments.
|
# Parse arguments.
|
||||||
subcommand, formula, = args.named
|
subcommand, *formulae = args.named
|
||||||
|
|
||||||
no_named_formula_commands = [
|
no_named_formula_commands = [
|
||||||
*Homebrew::Services::Commands::List::TRIGGERS,
|
*Homebrew::Services::Commands::List::TRIGGERS,
|
||||||
*Homebrew::Services::Commands::Cleanup::TRIGGERS,
|
*Homebrew::Services::Commands::Cleanup::TRIGGERS,
|
||||||
]
|
]
|
||||||
if no_named_formula_commands.include?(subcommand)
|
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?
|
raise UsageError, "The `#{subcommand}` subcommand does not accept the --all argument!" if args.all?
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
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?
|
targets = if args.all?
|
||||||
if subcommand == "start"
|
if subcommand == "start"
|
||||||
@ -133,8 +133,8 @@ module Homebrew
|
|||||||
else
|
else
|
||||||
Homebrew::Services::Formulae.available_services
|
Homebrew::Services::Formulae.available_services
|
||||||
end
|
end
|
||||||
elsif formula
|
elsif formulae.present?
|
||||||
[Homebrew::Services::FormulaWrapper.new(Formulary.factory(formula))]
|
formulae.map { |formula| Homebrew::Services::FormulaWrapper.new(Formulary.factory(formula)) }
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user