-
-
Notifications
You must be signed in to change notification settings - Fork 374
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
search: Show progress on stderr #4938
Conversation
@@ -2436,7 +2436,7 @@ static int pass_to_legacy_api(RzCore *core, int argc, const char **argv, RzOutpu | |||
static bool cmd_search_progress_cancel(void *user, size_t n_hits, RzSearchCancelReason invoke_reason) { | |||
if (user) { | |||
// we have RzCmdStateOutput state | |||
rz_cons_printf("Searching... hits: %" PFMTSZu "\r", n_hits); | |||
eprintf("Searching... hits: %" PFMTSZu "\r", n_hits); |
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 general yes, but didn't we want to remove the usage of eprintf
?
Maybe add a rz_cons_eprintf()
function.
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.
So we have at least a central point to start refactoring, once we start with the TUI.
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.
What would rz_cons_eprintf()
do?
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.
Never mind. I just recognized I probably don't understand rz_cons
. Keep it like this.
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 was about to push
diff --git a/librz/core/cmd/cmd_search.c b/librz/core/cmd/cmd_search.c
index 5c4135e22a..6636ed1389 100644
--- a/librz/core/cmd/cmd_search.c
+++ b/librz/core/cmd/cmd_search.c
@@ -2436,7 +2436,7 @@ static int pass_to_legacy_api(RzCore *core, int argc, const char **argv, RzOutpu
static bool cmd_search_progress_cancel(void *user, size_t n_hits, RzSearchCancelReason invoke_reason) {
if (user) {
// we have RzCmdStateOutput state
- eprintf("Searching... hits: %" PFMTSZu "\r", n_hits);
+ rz_cons_eprintf("Searching... hits: %" PFMTSZu "\r", n_hits);
}
return rz_cons_is_breaked();
}
diff --git a/librz/include/rz_cons.h b/librz/include/rz_cons.h
index 0e2bee4438..578cf9efb6 100644
--- a/librz/include/rz_cons.h
+++ b/librz/include/rz_cons.h
@@ -956,6 +956,7 @@ RZ_API void rz_cons_grep(const char *grep);
/* output */
RZ_API int rz_cons_printf(const char *format, ...) RZ_PRINTF_CHECK(1, 2);
RZ_API void rz_cons_printf_list(const char *format, va_list ap);
+#define rz_cons_eprintf(...) eprintf(__VA_ARGS__)
RZ_API void rz_cons_strcat(const char *str);
RZ_API void rz_cons_strcat_at(const char *str, int x, char y, int w, int h);
#define rz_cons_print(x) rz_cons_strcat(x)
but that rz_cons_eprintf()
macro is basically an outsider i.e. definitely not involved with the internals of rz_cons so I think using eprintf()
is 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.
lgtm as well
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.
But who knows you might want to control where stderr output is going to e.g. a TUI panel.
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.
This is just a simple pr though.
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.
Happy merging
Your checklist for this pull request
RZ_API
function and struct this PR changes.RZ_API
).Detailed description
This pr makes the search module show progress on stderr instead of stdout because the progress notifications:
Test plan
All builds are green.
Closing issues
...