Rework e? and e?? commands for better output

This commit is contained in:
Hertatijanto Hartono 2023-06-27 07:56:41 +07:00 committed by pancake
parent a2a4597924
commit 2f5e236c19
2 changed files with 16 additions and 10 deletions

View File

@ -163,7 +163,7 @@ R_API void r_config_list(RConfig *cfg, const char *str, int rad) {
const char *sfx = "";
const char *pfx = "";
int len = 0;
bool verbose = false;
bool found, verbose = false;
PJ *pj = NULL;
if (!IS_NULLSTR (str)) {
@ -215,17 +215,23 @@ R_API void r_config_list(RConfig *cfg, const char *str, int rad) {
case 2:
r_list_foreach (cfg->nodes, iter, node) {
if (!str || (str && (!strncmp (str, node->name, len)))) {
if (!str || !strncmp (str, node->name, len)) {
if (R_STR_ISNOTEMPTY (str)) {
cfg->cb_printf ("%s\n", r_str_get (node->desc));
} else {
cfg->cb_printf ("%20s: %s\n", node->name,
r_str_get (node->desc));
}
}
cfg->cb_printf ("%20s: %s\n", node->name, r_str_get (node->desc));
}
}
break;
case 3:
found = false;
r_list_foreach (cfg->nodes, iter, node) {
if (!str || (str && (!strcmp (str, node->name)))) {
found = true;
cfg->cb_printf ("%s\n", r_str_get (node->desc));
break;
}
}
if (!found) {
cfg->cb_printf ("Key not found. Try e??%s\n", str);
}
break;
case 's':
if (str && *str) {
r_list_foreach (cfg->nodes, iter, node) {

View File

@ -420,7 +420,7 @@ static int cmd_eval(void *data, const char *input) {
switch (input[1]) {
case '\0': r_core_cmd_help (core, help_msg_e); break;
case '?': r_config_list (core->config, input + 2, 2); break;
default: r_config_list (core->config, input + 1, 2); break;
default: r_config_list (core->config, input + 1, 3); break;
}
break;
case 't': // "et"