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

Add --stderr option #454

Merged
merged 1 commit into from
Oct 29, 2023
Merged

Add --stderr option #454

merged 1 commit into from
Oct 29, 2023

Conversation

benmelz
Copy link
Contributor

@benmelz benmelz commented Oct 28, 2023

As suggested by @MaxLap on #452

This option can stand on its own and is pretty straightforward (just need to point the logger to $stderr I believe), so I figured I would implement it before I work out --stdin.

Comment on lines +41 to +60
context 'when a logger is not passed' do
let(:logger) { nil }

it 'sets a default logger that writes to stdout' do
$stdout = StringIO.new
subject
expect(cli.send(:log).instance_variable_get(:'@out')).to eq($stdout)
end
end

context 'when passed the --stderr flag' do
let(:logger) { nil }
let(:args) { %w[--stderr] }

it 'sets a logger that writes to stderr' do
$stderr = StringIO.new
subject
expect(cli.send(:log).instance_variable_get(:'@out')).to eq($stderr)
end
end
Copy link
Contributor Author

@benmelz benmelz Oct 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are preeeetty gross, but they're as direct as I could make them without exposing parts of CLI and Logger that don't need to be exposed. Open to other ideas if anyone has any.

The $stdout/err = StringIO.new keeps these test runs from cluttering up the rspec output.

@sds sds merged commit 8dddb74 into sds:main Oct 29, 2023
34 checks passed
@sds
Copy link
Owner

sds commented Oct 29, 2023

Thanks!

@benmelz benmelz deleted the stderr branch January 20, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants