Skip to content

Commit

Permalink
Fixed default global help using outdated command description handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Sukairo-02 committed Aug 13, 2024
1 parent 88a7480 commit a2faec8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 15 additions & 2 deletions src/event-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a2faec8

Please sign in to comment.