diff --git a/lib/puma/cli.rb b/lib/puma/cli.rb index ff38d1ad54..16e0ace69a 100644 --- a/lib/puma/cli.rb +++ b/lib/puma/cli.rb @@ -185,6 +185,10 @@ def setup_options user_config.restart_command cmd end + o.on "-s", "--silent", "Do not log prompt messages other than errors" do + @events = Events.new NullIO.new, $stderr + end + o.on "-S", "--state PATH", "Where to store the state details" do |arg| user_config.state_path arg end diff --git a/test/test_cli.rb b/test/test_cli.rb index 5c3b2b1c80..096707050c 100644 --- a/test/test_cli.rb +++ b/test/test_cli.rb @@ -475,4 +475,15 @@ def test_environment_rails_env ensure ENV.delete 'RAILS_ENV' end + + def test_silent + cli = Puma::CLI.new ['--silent'] + cli.send(:setup_options) + + events = cli.instance_variable_get(:@events) + + assert_equal events.class, Puma::Events.null.class + assert_equal events.stdout.class, Puma::NullIO + assert_equal events.stderr, $stderr + end end