mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-11 10:38:39 +08:00
fix script run for now, to be seen if we can do better
This commit is contained in:
parent
99a82cf7d2
commit
06d61cdb7f
1 changed files with 13 additions and 5 deletions
|
@ -237,22 +237,30 @@ static int CmdScriptRun(const char *Cmd) {
|
||||||
CLIParserContext *ctx;
|
CLIParserContext *ctx;
|
||||||
CLIParserInit(&ctx, "script run",
|
CLIParserInit(&ctx, "script run",
|
||||||
"Run a Lua, Cmd or Python script",
|
"Run a Lua, Cmd or Python script",
|
||||||
"script run my_script.lua --my_script_args"
|
"script run my_script.lua -- --my_script_args"
|
||||||
);
|
);
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
|
arg_file1(NULL, NULL, "<filepath>", "script to run"),
|
||||||
|
arg_rem("--", "separator for script params"),
|
||||||
|
arg_strx0(NULL, NULL, "<params>", "params for the script"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
CLIParserFree(ctx);
|
|
||||||
// TODO possible to handle it with cliparser?
|
|
||||||
char preferredName[128] = {0};
|
char preferredName[128] = {0};
|
||||||
char arguments[256] = {0};
|
char arguments[256] = {0};
|
||||||
|
|
||||||
int name_len = 0;
|
int name_len = 0;
|
||||||
int arg_len = 0;
|
int arg_len = 0;
|
||||||
static uint8_t luascriptfile_idx = 0;
|
static uint8_t luascriptfile_idx = 0;
|
||||||
sscanf(Cmd, "%127s%n %255[^\n\r]%n", preferredName, &name_len, arguments, &arg_len);
|
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)preferredName, sizeof(preferredName), &name_len);
|
||||||
|
// this one removes all spaces
|
||||||
|
// CLIParamStrToBuf(arg_get_str(ctx, 2), (uint8_t *)arguments, sizeof(arguments), &arg_len);
|
||||||
|
CLIParserFree(ctx);
|
||||||
|
sscanf(Cmd + name_len + 1, "-- %255[^\n\r]%n", arguments, &arg_len);
|
||||||
|
if (arg_len == 0) {
|
||||||
|
sscanf(Cmd + name_len + 1, "%255[^\n\r]%n", arguments, &arg_len);
|
||||||
|
}
|
||||||
if (strlen(preferredName) == 0) {
|
if (strlen(preferredName) == 0) {
|
||||||
PrintAndLogEx(FAILED, "no script name provided");
|
PrintAndLogEx(FAILED, "no script name provided");
|
||||||
PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`script list`") " to see available scripts");
|
PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`script list`") " to see available scripts");
|
||||||
|
|
Loading…
Reference in a new issue