From a2faec8101d0f280ea891a779a8c0a137dabd693 Mon Sep 17 00:00:00 2001 From: Sukairo-02 Date: Tue, 13 Aug 2024 22:14:05 +0300 Subject: [PATCH] Fixed default global help using outdated command description handler --- package.json | 2 +- src/event-handler.ts | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index cf450f7..eaa983f 100755 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@drizzle-team/brocli", "type": "module", "author": "Drizzle Team", - "version": "0.10.0", + "version": "0.10.1", "description": "Modern type-safe way of building CLIs", "license": "Apache-2.0", "sideEffects": false, diff --git a/src/event-handler.ts b/src/event-handler.ts index 9cf9658..c3d9f6c 100644 --- a/src/event-handler.ts +++ b/src/event-handler.ts @@ -306,8 +306,21 @@ export const defaultEventHandler: EventHandler = async (event) => { const maxLength = commands.reduce((p, e) => e.name.length > p ? e.name.length : p, 0); const paddedLength = maxLength + padding; - const data = commands.map((s) => - ` ${s.name.padEnd(paddedLength)}${(s.shortDesc ?? s.desc)?.split('\n').shift()!}` + const data = commands.map((с) => + ` ${с.name.padEnd(paddedLength)}${ + (() => { + const desc = с.shortDesc ?? с.desc; + + if (!desc?.length) return ''; + + const split = desc.split('\n'); + const first = split.shift()!; + + const final = [first, ...split.map((s) => ''.padEnd(paddedLength + 2) + s)].join('\n'); + + return final; + })() + }` ) .join('\n'); console.log(data);