Skip to content

Commit 17df397

Browse files
committed
Fix argument parsing to make -Lj actually work
1 parent fcd464f commit 17df397

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

src/auto.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ static void print_content_with_length(RCore *core, const char *content, const ch
444444
}
445445

446446
// Add this function right after cmd_r2ai_a
447-
R_IPI void cmd_r2ai_logs(RCorePluginSession *cps) {
447+
R_IPI void cmd_r2ai_logs(RCorePluginSession *cps, const char *flags) {
448448
RCore *core = cps->core;
449449
R2AI_State *state = cps->data;
450450
// Get conversation
@@ -454,9 +454,7 @@ R_IPI void cmd_r2ai_logs(RCorePluginSession *cps) {
454454
return;
455455
}
456456

457-
const char *input = r_core_cmd_str (core, "r2ai");
458-
bool json_mode = input && strstr (input, "-Lj");
459-
free ((char *)input);
457+
bool json_mode = flags && strchr (flags, 'j');
460458

461459
if (json_mode) {
462460
PJ *pj = pj_new ();

src/r2ai.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ R_API void cmd_r2ai(RCorePluginSession *cps, const char *input) {
384384
} else if (r_str_startswith (input, "-LR")) {
385385
cmd_r2ai_lr (cps);
386386
} else if (r_str_startswith (input, "-L")) {
387-
cmd_r2ai_logs (cps);
387+
cmd_r2ai_logs (cps, input + 2);
388388
} else if (r_str_startswith (input, "-dr")) {
389389
cmd_r2ai_d (cps, r_str_trim_head_ro (input + 3), true);
390390
} else if (r_str_startswith (input, "-d")) {

src/r2ai.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ R_IPI R2AI_ChatResponse *r2ai_llmcall(RCorePluginSession *cps, R2AIArgs args);
355355
R2AI_ChatResponse *r2ai_rawtools_llmcall(RCorePluginSession *cps, R2AIArgs args);
356356

357357
R_IPI void cmd_r2ai_c(RCorePluginSession *cps);
358-
R_IPI void cmd_r2ai_logs(RCorePluginSession *cps);
358+
R_IPI void cmd_r2ai_logs(RCorePluginSession *cps, const char *flags);
359359
R_IPI void cmd_r2ai_lr(RCorePluginSession *cps);
360360

361361
/**

0 commit comments

Comments
 (0)