mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-08 16:56:09 +00:00
20 lines
767 B
TypeScript
20 lines
767 B
TypeScript
import { theme } from "../terminal/theme.js";
|
|
|
|
export type HelpExample = readonly [command: string, description: string];
|
|
|
|
function formatHelpExample(command: string, description: string): string {
|
|
return ` ${theme.command(command)}\n ${theme.muted(description)}`;
|
|
}
|
|
|
|
function formatHelpExampleLine(command: string, description: string): string {
|
|
if (!description) {
|
|
return ` ${theme.command(command)}`;
|
|
}
|
|
return ` ${theme.command(command)} ${theme.muted(`# ${description}`)}`;
|
|
}
|
|
|
|
export function formatHelpExamples(examples: ReadonlyArray<HelpExample>, inline = false): string {
|
|
const formatter = inline ? formatHelpExampleLine : formatHelpExample;
|
|
return examples.map(([command, description]) => formatter(command, description)).join("\n");
|
|
}
|