Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.

Commit 104fff2

Browse files
committed
Disable brew services restart --file=
1 parent 68336e9 commit 104fff2

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

Diff for: cmd/services.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ def services
9191
raise UsageError, "The `#{subcommand}` subcommand does not accept the --all argument!" if args.all?
9292
end
9393

94-
if ::Service::Commands::Start::TRIGGERS.include?(subcommand) && args.all? && args.file.present?
95-
raise UsageError, "The start subcommand does not accept the --all and --file= arguments at the same time!"
94+
if args.file
95+
if ::Service::Commands::Start::TRIGGERS.exclude?(subcommand)
96+
raise UsageError, "The `#{subcommand}` subcommand does not accept the --file= argument!"
97+
elsif args.all?
98+
raise UsageError, "The start subcommand does not accept the --all and --file= arguments at the same time!"
99+
end
96100
end
97101

98102
opoo "The --all argument overrides provided formula argument!" if formula.present? && args.all?
@@ -119,7 +123,7 @@ def services
119123
when *::Service::Commands::Info::TRIGGERS
120124
::Service::Commands::Info.run(targets, verbose: args.verbose?, json: args.json?)
121125
when *::Service::Commands::Restart::TRIGGERS
122-
::Service::Commands::Restart.run(targets, args.file, verbose: args.verbose?)
126+
::Service::Commands::Restart.run(targets, verbose: args.verbose?)
123127
when *::Service::Commands::Run::TRIGGERS
124128
::Service::Commands::Run.run(targets, verbose: args.verbose?)
125129
when *::Service::Commands::Start::TRIGGERS

Diff for: lib/service/commands/restart.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ module Restart
1212

1313
TRIGGERS = %w[restart relaunch reload r].freeze
1414

15-
def run(targets, custom_plist, verbose:)
15+
def run(targets, verbose:)
1616
return unless ServicesCli.check(targets)
1717

18-
odeprecated "the restart command with a service file" if custom_plist.present?
19-
2018
ran = []
2119
started = []
2220
targets.each do |service|

Diff for: spec/homebrew/commands/restart_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@
2121
expect(Service::ServicesCli).not_to receive(:stop)
2222
expect(Service::ServicesCli).to receive(:start).once
2323
service = OpenStruct.new(service_name: "name", loaded?: false)
24-
expect(described_class.run([service], nil, verbose: false)).to be_nil
24+
expect(described_class.run([service], verbose: false)).to be_nil
2525
end
2626

2727
it "starts if services are loaded with file" do
2828
expect(Service::ServicesCli).not_to receive(:run)
2929
expect(Service::ServicesCli).to receive(:start).once
3030
expect(Service::ServicesCli).to receive(:stop).once
3131
service = OpenStruct.new(service_name: "name", loaded?: true, service_file_present?: true)
32-
expect(described_class.run([service], nil, verbose: false)).to be_nil
32+
expect(described_class.run([service], verbose: false)).to be_nil
3333
end
3434

3535
it "runs if services are loaded without file" do
3636
expect(Service::ServicesCli).not_to receive(:start)
3737
expect(Service::ServicesCli).to receive(:run).once
3838
expect(Service::ServicesCli).to receive(:stop).once
3939
service = OpenStruct.new(service_name: "name", loaded?: true, service_file_present?: false)
40-
expect(described_class.run([service], nil, verbose: false)).to be_nil
40+
expect(described_class.run([service], verbose: false)).to be_nil
4141
end
4242
end
4343
end

0 commit comments

Comments
 (0)