From 11c7ead732dd9ec84964a190aa2380f0c6227c99 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Mon, 19 Apr 2021 01:43:26 +0200 Subject: [PATCH] Add -h/--help support to last commands --- client/src/cmdlft55xx.c | 12 +++++++++++- client/src/cmdmain.c | 12 +++++++++++- client/src/cmdscript.c | 26 ++++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c index 22847fcf5..1b98cc47d 100644 --- a/client/src/cmdlft55xx.c +++ b/client/src/cmdlft55xx.c @@ -96,7 +96,17 @@ static void arg_add_t55xx_downloadlink(void *at[], uint8_t *idx, uint8_t show, u } static int CmdT55xxCloneHelp(const char *Cmd) { - (void)Cmd; // Cmd is not used so far + CLIParserContext *ctx; + CLIParserInit(&ctx, "lf t55xx clonehelp", + "Display a list of available commands for cloning specific techs on T5xx tags", + "lf t55xx clonehelp" + ); + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); PrintAndLogEx(NORMAL, "For cloning specific techs on T55xx tags, see commands available in corresponding LF sub-menus, e.g.:"); PrintAndLogEx(NORMAL, _GREEN_("lf awid clone")); PrintAndLogEx(NORMAL, _GREEN_("lf destron clone")); diff --git a/client/src/cmdmain.c b/client/src/cmdmain.c index 94365e6d5..5c4152604 100644 --- a/client/src/cmdmain.c +++ b/client/src/cmdmain.c @@ -263,7 +263,17 @@ static int CmdMsleep(const char *Cmd) { } static int CmdQuit(const char *Cmd) { - (void)Cmd; // Cmd is not used so far + CLIParserContext *ctx; + CLIParserInit(&ctx, "quit", + "Quit the Proxmark3 client terminal", + "quit" + ); + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); return PM3_EFATAL; } diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c index 7c44c8978..cb378c75b 100644 --- a/client/src/cmdscript.c +++ b/client/src/cmdscript.c @@ -30,6 +30,7 @@ #include "proxmark3.h" #include "ui.h" #include "fileutils.h" +#include "cliparser.h" // cliparsing #ifdef HAVE_LUA_SWIG extern int luaopen_pm3(lua_State *L); @@ -198,7 +199,17 @@ static void set_python_paths(void) { * ending with .lua */ static int CmdScriptList(const char *Cmd) { - (void)Cmd; // Cmd is not used so far + CLIParserContext *ctx; + CLIParserInit(&ctx, "script list", + "List available Lua, Cmd and Python scripts", + "script list" + ); + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); PrintAndLogEx(NORMAL, "\n" _YELLOW_("[ Lua scripts ]")); int ret = searchAndList(LUA_SCRIPTS_SUBDIR, ".lua"); if (ret != PM3_SUCCESS) @@ -223,7 +234,18 @@ static int CmdScriptList(const char *Cmd) { * @return */ static int CmdScriptRun(const char *Cmd) { - + CLIParserContext *ctx; + CLIParserInit(&ctx, "script run", + "Run a Lua, Cmd or Python script", + "script run my_script.lua --my_script_args" + ); + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); + // TODO possible to handle it with cliparser? char preferredName[128] = {0}; char arguments[256] = {0};