Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a --silent option to the CLI #2803

Merged
merged 3 commits into from Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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