L/T commands: move help_msg_*[] arrays to top (#8021)

This commit is contained in:
Fangrui Song 2017-07-26 06:08:48 -07:00 committed by radare
parent 10bd4b5f95
commit c6a0d3617e
2 changed files with 37 additions and 28 deletions

View File

@ -3152,6 +3152,7 @@ R_API void r_core_cmd_init(RCore *core) {
r_cmd_add (core->rcmd, "cmp", "compare memory", &cmd_cmp);
r_cmd_add (core->rcmd, "seek", "seek to an offset", &cmd_seek);
r_cmd_add (core->rcmd, "Text", "Text log utility", &cmd_log);
cmd_log_init ();
r_cmd_add (core->rcmd, "t", "type information (cparse)", &cmd_type);
r_cmd_add (core->rcmd, "zign", "zignatures", &cmd_zign);
r_cmd_add (core->rcmd, "Section", "setup section io information", &cmd_section);

View File

@ -5,6 +5,38 @@
#include "r_cons.h"
#include "r_core.h"
// TODO #7967 help refactor: move to another place
static const char *help_msg_L[] = {
"Usage:", "L", "[-name][ file] # see oL, iL, dL, ...",
"L", "", "List all plugins loaded by RCore.lib",
"L-", "duk", "Unload plugin matching in filename",
"L", " blah."R_LIB_EXT, "Load plugin file",
NULL
};
static const char *help_msg_T[] = {
"Usage:", "T", "[-][ num|msg]",
"T", "", "List all Text log messages",
"T", " message", "Add new log message",
"T", " 123", "List log from 123",
"T", " 10 3", "List 3 log messages starting from 10",
"T*", "", "List in radare commands",
"T-", "", "Delete all logs",
"T-", " 123", "Delete logs before 123",
"Tl", "", "Get last log message id",
"Tj", "", "List in json format",
"Tm", " [idx]", "Display log messages without index",
"Ts", "", "List files in current directory (see pwd, cd)",
"TT", "", "Enter into the text log chat console",
NULL
};
// TODO #7967 help refactor: move L to another place
static void cmd_log_init(void) {
DEFINE_CMD_DESCRIPTOR (L);
DEFINE_CMD_DESCRIPTOR (T);
}
static int textlog_chat(RCore *core) {
char prompt[64];
char buf[1024];
@ -93,26 +125,9 @@ static int cmd_log(void *data, const char *input) {
case '-':
r_core_log_del (core, n);
break;
case '?': {
const char *help_msg[] = {
"Usage:", "T", "[-][ num|msg]",
"T", "", "List all Text log messages",
"T", " message", "Add new log message",
"T", " 123", "List log from 123",
"T", " 10 3", "List 3 log messages starting from 10",
"T*", "", "List in radare commands",
"T-", "", "Delete all logs",
"T-", " 123", "Delete logs before 123",
"Tl", "", "Get last log message id",
"Tj", "", "List in json format",
"Tm", " [idx]", "Display log messages without index",
"Ts", "", "List files in current directory (see pwd, cd)",
"TT", "", "Enter into the text log chat console",
NULL
};
r_core_cmd_help (core, help_msg);
}
break;
case '?':
r_core_cmd_help (core, help_msg_T);
break;
case 'T':
if (r_config_get_i (core->config, "scr.interactive")) {
textlog_chat (core);
@ -145,13 +160,6 @@ static int cmd_log(void *data, const char *input) {
static int cmd_plugins(void *data, const char *input) {
RCore *core = (RCore *) data;
const char *help_msg[] = {
"Usage:", "L", "[-name][ file] # see oL, iL, dL, ...",
"L", "", "List all plugins loaded by RCore.lib",
"L-", "duk", "Unload plugin matching in filename",
"L", " blah."R_LIB_EXT, "Load plugin file",
NULL
};
switch (input[0]) {
case 0:
r_lib_list (core->lib);
@ -163,7 +171,7 @@ static int cmd_plugins(void *data, const char *input) {
r_lib_open (core->lib, input + 2);
break;
case '?':
r_core_cmd_help (core, help_msg);
r_core_cmd_help (core, help_msg_L);
break;
}
return 0;