mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
First attempt at dumping all help: proxmark3 --fulltext
This commit is contained in:
parent
11c7ead732
commit
008a0b5ab4
3 changed files with 47 additions and 16 deletions
|
@ -195,12 +195,22 @@ void CmdsHelp(const command_t Commands[]) {
|
|||
int CmdsParse(const command_t Commands[], const char *Cmd) {
|
||||
// Help dump children
|
||||
if (strcmp(Cmd, "XX_internal_command_dump_XX") == 0) {
|
||||
dumpCommandsRecursive(Commands, 0);
|
||||
dumpCommandsRecursive(Commands, 0, false);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
// Help dump children with help
|
||||
if (strcmp(Cmd, "XX_internal_command_dump_full_XX") == 0) {
|
||||
dumpCommandsRecursive(Commands, 0, true);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
// Markdown help dump children
|
||||
if (strcmp(Cmd, "XX_internal_command_dump_markdown_XX") == 0) {
|
||||
dumpCommandsRecursive(Commands, 1);
|
||||
dumpCommandsRecursive(Commands, 1, false);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
// Markdown help dump children with help
|
||||
if (strcmp(Cmd, "XX_internal_command_dump_markdown_help_XX") == 0) {
|
||||
dumpCommandsRecursive(Commands, 1, true);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -290,7 +300,7 @@ int CmdsParse(const command_t Commands[], const char *Cmd) {
|
|||
static char pparent[512] = {0};
|
||||
static char *parent = pparent;
|
||||
|
||||
void dumpCommandsRecursive(const command_t cmds[], int markdown) {
|
||||
void dumpCommandsRecursive(const command_t cmds[], int markdown, bool full_help) {
|
||||
if (cmds[0].Name == NULL) return;
|
||||
|
||||
int i = 0;
|
||||
|
@ -301,7 +311,7 @@ void dumpCommandsRecursive(const command_t cmds[], int markdown) {
|
|||
if (markdown) {
|
||||
PrintAndLogEx(NORMAL, "|%-*s|%-*s|%s", w_cmd, "command", w_off, "offline", "description");
|
||||
PrintAndLogEx(NORMAL, "|%-*s|%-*s|%s", w_cmd, "-------", w_off, "-------", "-----------");
|
||||
} else {
|
||||
} else if (! full_help) {
|
||||
PrintAndLogEx(NORMAL, "%-*s|%-*s|%s", w_cmd, "command", w_off, "offline", "description");
|
||||
PrintAndLogEx(NORMAL, "%-*s|%-*s|%s", w_cmd, "-------", w_off, "-------", "-----------");
|
||||
}
|
||||
|
@ -317,8 +327,13 @@ void dumpCommandsRecursive(const command_t cmds[], int markdown) {
|
|||
cmd_offline = "Y";
|
||||
if (markdown)
|
||||
PrintAndLogEx(NORMAL, "|`%s%-*s`|%-*s|`%s`", parent, w_cmd - (int)strlen(parent) - 2, cmds[i].Name, w_off, cmd_offline, cmds[i].Help);
|
||||
else
|
||||
else if (full_help) {
|
||||
PrintAndLogEx(NORMAL, "---------------------------------------------------------------------------------------");
|
||||
PrintAndLogEx(NORMAL, _RED_("%s%-*s\n") "available offline: %s", parent, w_cmd - (int)strlen(parent), cmds[i].Name, cmds[i].IsAvailable()?_GREEN_("yes"):_RED_("no"));
|
||||
cmds[i].Parse("--help");
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "%s%-*s|%-*s|%s", parent, w_cmd - (int)strlen(parent), cmds[i].Name, w_off, cmd_offline, cmds[i].Help);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
|
@ -330,8 +345,12 @@ void dumpCommandsRecursive(const command_t cmds[], int markdown) {
|
|||
if ((cmds[i].Name[0] == '-' || strlen(cmds[i].Name) == 0) && ++i) continue;
|
||||
if (cmds[i].Help[0] != '{' && ++i) continue;
|
||||
|
||||
if (full_help) {
|
||||
PrintAndLogEx(NORMAL, "=======================================================================================");
|
||||
PrintAndLogEx(NORMAL, _RED_("%s%s\n\n ")_CYAN_("%s\n"), parent, cmds[i].Name, cmds[i].Help);
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "### %s%s\n\n %s\n", parent, cmds[i].Name, cmds[i].Help);
|
||||
|
||||
}
|
||||
char currentparent[512] = {0};
|
||||
snprintf(currentparent, sizeof currentparent, "%s%s ", parent, cmds[i].Name);
|
||||
char *old_parent = parent;
|
||||
|
@ -340,8 +359,11 @@ void dumpCommandsRecursive(const command_t cmds[], int markdown) {
|
|||
// in turn calls the CmdsParse above.
|
||||
if (markdown)
|
||||
cmds[i].Parse("XX_internal_command_dump_markdown_XX");
|
||||
else
|
||||
else if (full_help) {
|
||||
cmds[i].Parse("XX_internal_command_dump_full_XX");
|
||||
} else {
|
||||
cmds[i].Parse("XX_internal_command_dump_XX");
|
||||
}
|
||||
|
||||
parent = old_parent;
|
||||
++i;
|
||||
|
|
|
@ -54,6 +54,6 @@ void CmdsHelp(const command_t Commands[]);
|
|||
void CmdsLS(const command_t Commands[]);
|
||||
// Parse a command line
|
||||
int CmdsParse(const command_t Commands[], const char *Cmd);
|
||||
void dumpCommandsRecursive(const command_t cmds[], int markdown);
|
||||
void dumpCommandsRecursive(const command_t cmds[], int markdown, bool full_help);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -455,14 +455,14 @@ check_script:
|
|||
}
|
||||
|
||||
#ifndef LIBPM3
|
||||
static void dumpAllHelp(int markdown) {
|
||||
static void dumpAllHelp(int markdown, bool full_help) {
|
||||
session.help_dump_mode = true;
|
||||
PrintAndLogEx(NORMAL, "\n%sProxmark3 command dump%s\n\n", markdown ? "# " : "", markdown ? "" : "\n======================");
|
||||
PrintAndLogEx(NORMAL, "Some commands are available only if a Proxmark3 is actually connected.%s\n", markdown ? " " : "");
|
||||
PrintAndLogEx(NORMAL, "Check column \"offline\" for their availability.\n");
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
command_t *cmds = getTopLevelCommandTable();
|
||||
dumpCommandsRecursive(cmds, markdown);
|
||||
dumpCommandsRecursive(cmds, markdown, full_help);
|
||||
session.help_dump_mode = false;
|
||||
}
|
||||
#endif //LIBPM3
|
||||
|
@ -553,7 +553,7 @@ static void set_my_user_directory(void) {
|
|||
#ifndef LIBPM3
|
||||
static void show_help(bool showFullHelp, char *exec_name) {
|
||||
|
||||
PrintAndLogEx(NORMAL, "\nsyntax: %s [-h|-t|-m]", exec_name);
|
||||
PrintAndLogEx(NORMAL, "\nsyntax: %s [-h|-t|-m|--fulltext]", exec_name);
|
||||
PrintAndLogEx(NORMAL, " %s [[-p] <port>] [-b] [-w] [-f] [-c <command>]|[-l <lua_script_file>]|[-s <cmd_script_file>] [-i] [-d <0|1|2>]", exec_name);
|
||||
PrintAndLogEx(NORMAL, " %s [-p] <port> --flash [--unlock-bootloader] [--image <imagefile>]+ [-w] [-f] [-d <0|1|2>]", exec_name);
|
||||
|
||||
|
@ -567,8 +567,9 @@ static void show_help(bool showFullHelp, char *exec_name) {
|
|||
PrintAndLogEx(NORMAL, " -f/--flush output will be flushed after every print");
|
||||
PrintAndLogEx(NORMAL, " -d/--debug <0|1|2> set debugmode");
|
||||
PrintAndLogEx(NORMAL, "\nOptions in client mode:");
|
||||
PrintAndLogEx(NORMAL, " -t/--text dump all interactive command's help at once");
|
||||
PrintAndLogEx(NORMAL, " -m/--markdown dump all interactive help at once in markdown syntax");
|
||||
PrintAndLogEx(NORMAL, " -t/--text dump all interactive command list at once");
|
||||
PrintAndLogEx(NORMAL, " --fulltext dump all interactive command's help at once");
|
||||
PrintAndLogEx(NORMAL, " -m/--markdown dump all interactive command list at once in markdown syntax");
|
||||
PrintAndLogEx(NORMAL, " -b/--baud serial port speed (only needed for physical UART, not for USB-CDC or BT)");
|
||||
PrintAndLogEx(NORMAL, " -c/--command <command> execute one Proxmark3 command (or several separated by ';').");
|
||||
PrintAndLogEx(NORMAL, " -l/--lua <lua script file> execute lua script.");
|
||||
|
@ -823,14 +824,22 @@ int main(int argc, char *argv[]) {
|
|||
if (strcmp(argv[i], "-t") == 0 || strcmp(argv[i], "--text") == 0) {
|
||||
g_printAndLog = PRINTANDLOG_PRINT;
|
||||
show_help(false, exec_name);
|
||||
dumpAllHelp(0);
|
||||
dumpAllHelp(0, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// dump help
|
||||
if (strcmp(argv[i], "--fulltext") == 0) {
|
||||
g_printAndLog = PRINTANDLOG_PRINT;
|
||||
show_help(false, exec_name);
|
||||
dumpAllHelp(0, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// dump markup
|
||||
if (strcmp(argv[i], "-m") == 0 || strcmp(argv[i], "--markdown") == 0) {
|
||||
g_printAndLog = PRINTANDLOG_PRINT;
|
||||
dumpAllHelp(1);
|
||||
dumpAllHelp(1, false);
|
||||
return 0;
|
||||
}
|
||||
// print client version
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue