Skip to content

Commit

Permalink
Initial support for r2pipe { command
Browse files Browse the repository at this point in the history
  • Loading branch information
radare authored and trufae committed Oct 8, 2024
1 parent 6c09b7c commit 1c17c20
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/agent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ global.r2pipe = {
}
};

function r2pipe2(arg: string) {
const query = JSON.parse(arg);
const cmd = query.cmd;
const res: any = perform({ command: cmd });
const objres = {
res: res[0].value,
code: 0
}
console.log(JSON.stringify(objres));
}

const commandHandlers = {
'!': [system.runSystemCommand, 'execute program with system'],
'?': [expr.evalNum, 'evaluate number'],
Expand Down Expand Up @@ -355,6 +366,9 @@ function perform(params: any) {
if (command.startsWith("!")) {
command = "! " + command.substr(1);
}
if (command.startsWith("{")) {
return r2pipe2(command);
}
const tokens = command.split(/ /).map((c: any) => c.trim()).filter((x: any) => x);
const [name, ...args] = tokens;
if (typeof name === 'undefined') {
Expand Down

0 comments on commit 1c17c20

Please sign in to comment.