From ed68eda901f96d4c51e56ef3f365630d7d63f268 Mon Sep 17 00:00:00 2001 From: Jason Jafari Date: Sat, 31 Oct 2026 11:50:19 -0400 Subject: [PATCH] fix(help): use explicit indentation instead of console.group The help output was indented by unclosed console.group() calls, which Bun keeps applying to every subsequent line. Because groups were never closed with console.groupEnd(), indentation accumulated per nesting level and pushed deep entries (e.g. "jj portainer test") far to the right. Replace the group-based helpers with an explicit INDENT constant and a depth parameter in generateHelp(), so each level is indented deterministically and the layout is stable regardless of console state. --- cli/help.ts | 21 +++++++++------------ package.json | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/cli/help.ts b/cli/help.ts index f2af8c9..f29fd13 100644 --- a/cli/help.ts +++ b/cli/help.ts @@ -4,13 +4,7 @@ import fs from "fs-extra"; const cliConfig: any = {}; -const emphasizeText = (...args) => { - console.log(chalk.bold(...args)); -}; - -const italicEmphasizeGreen = (...args) => { - console.group(chalk.italic.green.bold(...args)); -}; +const INDENT = " "; const formatCommandSection = (cmd, prefixCmd, maxLen = 25) => { const formattedCmd = prefixCmd ? `${prefixCmd} ${cmd}` : cmd; @@ -25,22 +19,24 @@ const formatHelpSection = (desc, prefixDesc) => { return formattedDesc; }; -const generateHelp = ({ cmds, prefixCmd = "", prefixDesc = "" }) => { +const generateHelp = ({ cmds, prefixCmd = "", prefixDesc = "", depth = 0 }) => { + const indent = INDENT.repeat(depth); for (const cmd of cmds) { const commandLabel = cmd?.postCommand ? `${cmd?.key} ${cmd?.postCommand}` : cmd?.key; if (cmd?.mainTitle) { - italicEmphasizeGreen(cmd?.mainTitle); + console.log(indent + chalk.italic.green.bold(cmd.mainTitle)); if (cmd?.keys?.length > 0) { generateHelp({ cmds: cmd?.keys || [], prefixCmd: cmd?.key, prefixDesc: cmd?.desc, + depth: depth + 1, }); } else { - emphasizeText(formatCommandSection(commandLabel, prefixCmd, cmd?.maxLength), formatHelpSection(cmd?.desc, prefixDesc)); + console.log(indent + INDENT + chalk.bold(formatCommandSection(commandLabel, prefixCmd, cmd?.maxLength), formatHelpSection(cmd?.desc, prefixDesc))); } } else { - emphasizeText(formatCommandSection(commandLabel, prefixCmd, cmd?.maxLength), formatHelpSection(cmd?.desc, prefixDesc)); + console.log(indent + chalk.bold(formatCommandSection(commandLabel, prefixCmd, cmd?.maxLength), formatHelpSection(cmd?.desc, prefixDesc))); } } }; @@ -78,7 +74,7 @@ const cliHelp = async () => { return; } console.log(chalk.blue.italic.bold("Usage: jj ")); - console.group(chalk.blue.italic.bold("Commands:")); + console.log(chalk.blue.italic.bold("Commands:")); cliConfig.commandsObject = getJJConfigByKeyChain(`commands`); cliConfig.commandList = Object.keys(cliConfig.commandsObject).map((cmdKey) => ({ @@ -88,6 +84,7 @@ const cliHelp = async () => { generateHelp({ cmds: cliConfig.commandList, + depth: 1, }); return; diff --git a/package.json b/package.json index d16b914..40329fb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@sarava-npm-packages/jj-command-line", "description": "jj cli", - "version": "2.1.9", + "version": "2.1.10", "author": "Jason Jafari", "bin": { "jj": "./jj.sh"