mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -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;
|
||||
|
||||
PrintAndLogEx(NORMAL, "### %s%s\n\n %s\n", parent, cmds[i].Name, cmds[i].Help);
|
||||
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue