fix: wrap cli banner tagline
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
import { resolveCommitHash } from "../infra/git-commit.js";
|
import { resolveCommitHash } from "../infra/git-commit.js";
|
||||||
|
import { visibleWidth } from "../terminal/ansi.js";
|
||||||
import { isRich, theme } from "../terminal/theme.js";
|
import { isRich, theme } from "../terminal/theme.js";
|
||||||
import { pickTagline, type TaglineOptions } from "./tagline.js";
|
import { pickTagline, type TaglineOptions } from "./tagline.js";
|
||||||
|
|
||||||
type BannerOptions = TaglineOptions & {
|
type BannerOptions = TaglineOptions & {
|
||||||
argv?: string[];
|
argv?: string[];
|
||||||
commit?: string | null;
|
commit?: string | null;
|
||||||
|
columns?: number;
|
||||||
richTty?: boolean;
|
richTty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -36,12 +38,28 @@ export function formatCliBannerLine(version: string, options: BannerOptions = {}
|
|||||||
const tagline = pickTagline(options);
|
const tagline = pickTagline(options);
|
||||||
const rich = options.richTty ?? isRich();
|
const rich = options.richTty ?? isRich();
|
||||||
const title = "🦞 Clawdbot";
|
const title = "🦞 Clawdbot";
|
||||||
|
const prefix = "🦞 ";
|
||||||
|
const columns = options.columns ?? process.stdout.columns ?? 120;
|
||||||
|
const plainFullLine = `${title} ${version} (${commitLabel}) — ${tagline}`;
|
||||||
|
const fitsOnOneLine = visibleWidth(plainFullLine) <= columns;
|
||||||
if (rich) {
|
if (rich) {
|
||||||
return `${theme.heading(title)} ${theme.info(version)} ${theme.muted(
|
if (fitsOnOneLine) {
|
||||||
|
return `${theme.heading(title)} ${theme.info(version)} ${theme.muted(
|
||||||
|
`(${commitLabel})`,
|
||||||
|
)} ${theme.muted("—")} ${theme.accentDim(tagline)}`;
|
||||||
|
}
|
||||||
|
const line1 = `${theme.heading(title)} ${theme.info(version)} ${theme.muted(
|
||||||
`(${commitLabel})`,
|
`(${commitLabel})`,
|
||||||
)} ${theme.muted("—")} ${theme.accentDim(tagline)}`;
|
)}`;
|
||||||
|
const line2 = `${" ".repeat(prefix.length)}${theme.muted("—")} ${theme.accentDim(tagline)}`;
|
||||||
|
return `${line1}\n${line2}`;
|
||||||
}
|
}
|
||||||
return `${title} ${version} (${commitLabel}) — ${tagline}`;
|
if (fitsOnOneLine) {
|
||||||
|
return plainFullLine;
|
||||||
|
}
|
||||||
|
const line1 = `${title} ${version} (${commitLabel})`;
|
||||||
|
const line2 = `${" ".repeat(prefix.length)}— ${tagline}`;
|
||||||
|
return `${line1}\n${line2}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LOBSTER_ASCII = [
|
const LOBSTER_ASCII = [
|
||||||
|
|||||||
Reference in New Issue
Block a user