-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
build_runner: add option to clear console when watching #24122
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: master
Are you sure you want to change the base?
Conversation
lib/compiler/build_runner.zig
Outdated
@@ -266,6 +267,8 @@ pub fn main() !void { | |||
prominent_compile_errors = true; | |||
} else if (mem.eql(u8, arg, "--watch")) { | |||
watch = true; | |||
} else if (mem.eql(u8, arg, "--with-clear")) { |
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.
I would personally prefer something like --watch-clear
. The with
doesn't really add any clarity, but watch
clarifies that it affects --watch
.
It also needs to be added to the help text in usage()
.
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.
I would suggest that --watch=clear
might be even better?
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.
That works for me too. Though I don't know if we expect to add other options that affect --watch
in the future?
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.
I think let's YAGNI this for the minute: --watch=clear
feels to me like the simplest approach for now.
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.
Seen this after pushing update to --watch-clear
, will update to --watch=clear
.
@@ -484,6 +487,10 @@ pub fn main() !void { | |||
var debounce_timeout: Watch.Timeout = .none; | |||
while (true) switch (try w.wait(gpa, debounce_timeout)) { | |||
.timeout => { | |||
if (watch_clear) { | |||
try std.io.getStdOut().writeAll("\x1B[2J\x1B[H"); |
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.
In my opinion, "\x1B[2J\x1B[H"
should be moved into std.io.tty
.
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.
Also note that std.Progress
already has code like this so that could be refactored.
clearing is pretty aggressive, have you considered simply adding a newline instead? |
FWIW, I absolutely want the "clear" option, and have done for a while. With the reference trace and command also in the output, just blank lines don't separate things enough. I would really like my Ideally we could replace just the previous |
I agree with @mlugg on this one. I usually just want to expend as little as possible of my attention trying to locate the error in the log and just go back to fixing the code. I was wondering if it would be better to also allow people to specify their own separator either as a flag or as an option in |
As described in #23472.
Running
zig build
with-fincremental
and--watch
it's a bit hard to identify what's the up-to-date error state.This PR allows you to opt-in having the screen cleared on debounce timeout.