-
Notifications
You must be signed in to change notification settings - Fork 980
refactor: Simplify abstracted stdout/stderr #4517
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
base: main
Are you sure you want to change the base?
Conversation
In a lot of cases, `Process` will create a boxed `Writer` just then to create a `ColorableTerminal` from it. This bypasses some of those steps, simplifying the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!
src/process/filesource.rs
Outdated
|
||
fn terminal(&self, process: &Process) -> ColorableTerminal { | ||
ColorableTerminal::new(StreamSelector::TestWriter(self.clone()), process) | ||
ColorableTerminal::test(self, process) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: is it true that this line has been changed here first and a second time in the following commit? Would that mean at least one of the commits are not compiling, thus violating the rules of atomic commits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right; I forgot to test my history edits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@epage Sorry, but I don't see the fix being applied here? I think .clone()
is needed from the start if I'm not mistaken. Maybe you are not checking with the test
feature on?
To write colored output on a locked stream, you had to:
process.stdout()
to get aBox<dyn Writer>
Writer::terminal(process)
to get aColorableTerminal
(enum)ColorableTerminal::lock
to get aColorableTerminalLocked
(enum)This cuts out the first step, making sure everything goes through
ColorableTerminal
.