Skip to content

Commit

Permalink
Adds a --silent option to the CLI (puma#2803)
Browse files Browse the repository at this point in the history
* Adds a --silent option to the CLI

* Fixes silent opt not to silence stderr

* Removes un-used arg variable from CLI opt block handler
  • Loading branch information
gottfrois authored and JuanitoFatas committed Sep 9, 2022
1 parent 1a8bd06 commit 3b8d902
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/puma/cli.rb
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions test/test_cli.rb
Expand Up @@ -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

0 comments on commit 3b8d902

Please sign in to comment.