From 41f44685045bb629960996ad60e98279d74f2f76 Mon Sep 17 00:00:00 2001 From: pancake Date: Sat, 3 Feb 2024 13:14:42 +0900 Subject: [PATCH] Group r2 and json command modifiers in the help message --- src/agent/index.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/agent/index.ts b/src/agent/index.ts index e9db4c4b..9cd426bc 100644 --- a/src/agent/index.ts +++ b/src/agent/index.ts @@ -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');