Implement the 'es' command to list eval spaces and keys

This commit is contained in:
pancake 2017-10-23 03:18:07 +02:00
parent 250f7db229
commit 3379258f87
3 changed files with 47 additions and 2 deletions

View File

@ -189,6 +189,42 @@ R_API void r_config_list(RConfig *cfg, const char *str, int rad) {
}
}
break;
case 's':
if (str && *str) {
r_list_foreach (cfg->nodes, iter, node) {
char *space = strdup (node->name);
char *dot = strchr (space, '.');
if (dot) {
*dot = 0;
}
if (!strcmp (str, space)) {
cfg->cb_printf ("%s\n", node->name);
}
free (space);
}
} else {
char *oldSpace = NULL;
r_list_foreach (cfg->nodes, iter, node) {
char *space = strdup (node->name);
char *dot = strchr (space, '.');
if (dot) {
*dot = 0;
}
if (oldSpace) {
if (!strcmp (space, oldSpace)) {
free (space);
continue;
}
free (oldSpace);
oldSpace = space;
} else {
oldSpace = space;
}
cfg->cb_printf ("%s\n", space);
}
free (oldSpace);
}
break;
case 'v':
verbose = true;
r_list_foreach (cfg->nodes, iter, node) {

View File

@ -20,6 +20,7 @@ static const char *help_msg_e[] = {
"ej", "", "list config vars in JSON",
"env", " [k[=v]]", "get/set environment variable",
"er", " [key]", "set config key as readonly. no way back",
"es", " [space]", "list all eval spaces [or keys]",
"et", " [key]", "show type of given config variable",
"ev", " [key]", "list config vars in verbose format",
"evj", " [key]", "list config vars in verbose format in JSON",
@ -451,6 +452,9 @@ static int cmd_eval(void *data, const char *input) {
if (!r_config_toggle (core->config, input))
eprintf ("r_config: '%s' is not a boolean variable.\n", input);
break;
case 's':
r_config_list (core->config, (input[1])? input + 1: NULL, 's');
break;
case '-':
r_core_config_init (core);
//eprintf ("BUG: 'e-' command locks the eval hashtable. patches are welcome :)\n");
@ -467,9 +471,12 @@ static int cmd_eval(void *data, const char *input) {
case 'r':
if (input[1]) {
const char *key = input+((input[1]==' ')?2:1);
if (!r_config_readonly (core->config, key))
if (!r_config_readonly (core->config, key)) {
eprintf ("cannot find key '%s'\n", key);
} else eprintf ("Usage: er [key]\n");
}
} else {
eprintf ("Usage: er [key]\n");
}
break;
case ' ': r_config_eval (core->config, input+1); break;
default: r_config_eval (core->config, input); break;

View File

@ -2504,9 +2504,11 @@ static void agraph_print_nodes(const RAGraph *g) {
}
}
#if 0
static int find_ascii_edge(const AEdge *a, const AEdge *b) {
return a->from == b->from && a->to == b->to? 0: 1;
}
#endif
static int get_nth (const RAGraph *g, RANode *src, RANode *dst) {
RListIter *itn;