-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Extend format status output - Allow to change also order of description in NINJA_STATUS #1045
base: master
Are you sure you want to change the base?
Conversation
Hi! Can you review my patches? |
@pali can you collapse all these patches into one? I believe that will make it easier to be reviewed. |
Hm.. there are more patches as before... and some not mine. Have you did some git push --force? Looks like there are more changes since I created this pull request in Oct 2015. |
I cherry-picked those two my commits on top of current master. |
Is there anything wrong with my patch? |
@tfarina so it is OK now? Ready for merge? |
@@ -168,6 +168,9 @@ string BuildStatus::FormatProgressStatus( | |||
string out; | |||
char buf[32]; | |||
int percent; | |||
char total_edges_str[32]; | |||
snprintf(total_edges_str, sizeof(total_edges_str), "%d", total_edges_); |
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.
Note: total_edges_ can change over the course of a build, so this isn't guaranteed. The most common thing in fact is for the total edge count to be overestimated and then reduced in the case where a command doesn't modify its outputs.
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 that this is not a problem. It is just used as an estimate for length alignment. It just provide better output for next print...
Sorry for not looking at this earlier. The single pull request with a vague description makes it easy to overlook! I think the %d change is pretty reasonable but I think the alignment one may not work as you expect. |
Alignment in all snprintf calls make sure that all "%d" formats will be aligned to same length. As during one FormatProgressStatus call is total_edges the highest number which can "%_d" format. Also that number total_edges_ is not directly used. But its logarithm, so if number of edges do not start exponentially increasing or decreasing then output is pretty constant and good aligned also when doing progress. |
@evmar Let me know if you are going accept this patch in some way and if something is needed to rework... |
@evmar: PING |
@evmar gentle PING |
This looks quite useful, especially if we add support for colors in NINJA_STATUS. Would you be willing to rebase this on current master? |
I already did it more times. But nobody replied. |
So is still somebody interesting in this patch after rebasing? And can review it? |
Yes, I would do it. |
So when updating status output on terminal, make sure that all numbers will be always aligned at same length. Even if progress variables change number of characters.
@jhasse Done! |
Thanks :) Please have a look at the CI failures. |
This commit adds new format string %d for printing description. When %d is not specified in NINJA_STATUS, then description is automatically printed at the end of line. This allows to add additional strings after description, for example changing colors on ANSI terminals via NINJA_STATUS variable.
Done! |
Thanks. This will come in handy when #1494 is merged. Code looks good, though I don't like the need for |
printf's
I used lowercase |
Ah, I thought that was because it would clash with %d from the description otherwise. Sorry, I didn't read it more clearly. Can you split the PR in "Align all edge numbers to same length when formatting output" (not sure if we want this by default, needs discussion) and "Allow to change also order of description in NINJA_STATUS"? |
Reason for aligning is that output format does not change so drastically when printing it in-place on terminal. Before this change, when updating Second commit allows to put description at any position and to have it on stable position, that alignment from first commit is really needed. |
I understand the reasoning. Users may rely on the old behavior though and it changes Ninja's default output. A way to change the behavior, maybe
Yeah, keep that. I was completely wrong there, nvm ;) |
No, this is independent of #1494. I'm still not sure about the "Align all edge numbers to same length when formatting output" part. What do you think about
? (btw: As for all frontend stuff, I'm a fan of #1210 instead of extending Ninja itself) |
And what with %u, %r and %f then? |
BTW, one of my design regrets in Ninja is that we have this mechanism for generating command line strings internally (via "$foo ${other}") and then we didn't reuse it for status. Not sure if it's worth thinking about here though. |
Align all edge numbers to same length when formatting output
So when updating status output on terminal, make sure that all numbers will
be always aligned at same length. Even if progress variables change number
of characters.
Allow to change also order of description in NINJA_STATUS
This commit adds new format string %d for printing description. When %d is
not specified in NINJA_STATUS, then description is automatically printed at
the end of line.
This allows to add additional strings after description, for example
changing colors on ANSI terminals via NINJA_STATUS variable.