Skip to content

Commit 3f3c2f6

Browse files
authored
Adds a --silent option to the CLI (#2803)
* Adds a --silent option to the CLI * Fixes silent opt not to silence stderr * Removes un-used arg variable from CLI opt block handler
1 parent 03be0aa commit 3f3c2f6

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/puma/cli.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ def setup_options
185185
user_config.restart_command cmd
186186
end
187187

188+
o.on "-s", "--silent", "Do not log prompt messages other than errors" do
189+
@events = Events.new NullIO.new, $stderr
190+
end
191+
188192
o.on "-S", "--state PATH", "Where to store the state details" do |arg|
189193
user_config.state_path arg
190194
end

test/test_cli.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,4 +475,15 @@ def test_environment_rails_env
475475
ensure
476476
ENV.delete 'RAILS_ENV'
477477
end
478+
479+
def test_silent
480+
cli = Puma::CLI.new ['--silent']
481+
cli.send(:setup_options)
482+
483+
events = cli.instance_variable_get(:@events)
484+
485+
assert_equal events.class, Puma::Events.null.class
486+
assert_equal events.stdout.class, Puma::NullIO
487+
assert_equal events.stderr, $stderr
488+
end
478489
end

0 commit comments

Comments
 (0)