Skip to content

Commit

Permalink
Group r2 and json command modifiers in the help message
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Feb 3, 2024
1 parent 465bdef commit 41f4468
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/agent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,24 @@ function getHelpMessage(prefix: string): string {
// TODO: only filter those for top level commands, maybe handy to show them too
return !(k.endsWith('?') || k.endsWith('j') || k.endsWith('q')); // || k.endsWith('.'));
})
.filter((k) => {
const fcn = (commandHandlers as any)[k];
return (typeof fcn === "object");
})
.map((k) => {
const fcn = (commandHandlers as any)[k];
if (typeof fcn === "object") {
const desc = fcn[1];
const args = fcn[2] || "";
const cmd = k + ' ' + args;
return ':' + utils.padString(cmd, 25) + desc;
const haveJson = (commandHandlers as any)[k + 'j'];
const haveR2 = (commandHandlers as any)[k + '*'];
let mods = "";
if (haveJson || haveR2) {
mods = "[" + (haveJson?"j":"") + (haveR2?"*":"") + "]";
}
const cmd = k + mods + ' ' + args;
// show subcommands if any (check for 'j' and '*')
return ':' + utils.padString(cmd, 20) + desc;
}
return ":" + k;
}).join('\n');
Expand Down

0 comments on commit 41f4468

Please sign in to comment.