Add -h/--help support to last commands

This commit is contained in:
Philippe Teuwen 2021-04-19 01:43:26 +02:00
commit 11c7ead732
3 changed files with 46 additions and 4 deletions

View file

@ -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"));

View file

@ -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;
}

View file

@ -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};