Skip to content

Commit b4c1bd9

Browse files
authored
Add bunny colors to table header and command overview (#102)
* add bunny colors to table head, and help overview * changeset * fix order import order * resolve mentioned issues
1 parent 0084ba8 commit b4c1bd9

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

.changeset/tall-suns-vanish.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@bunny.net/cli": patch
3+
---
4+
5+
Added bunny color to the table head and also the help overview.

packages/cli/src/core/define-namespace.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Argv, CommandModule } from "yargs";
2-
2+
import { bunny } from "./colors.ts";
33
/**
44
* Groups subcommands under a parent namespace. Running the namespace
55
* without a subcommand shows help.
@@ -32,8 +32,16 @@ export function defineNamespace(
3232
for (const sub of subcommands) yargs.command(sub);
3333
return yargs;
3434
},
35-
handler: () => {
36-
yRef.showHelp("log");
35+
handler: async () => {
36+
try {
37+
const helpText = await yRef.getHelp();
38+
const colored = helpText
39+
.replace(/^Commands:/m, bunny.bold("Commands:"))
40+
.replace(/^Options:/m, bunny.bold("Options:"));
41+
console.log(colored);
42+
} catch (err) {
43+
console.error("Failed to load help text:", err);
44+
}
3745
},
3846
};
3947
}

packages/cli/src/core/format.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import chalk from "chalk";
22
import Table from "cli-table3";
3+
import { bunny } from "./colors.ts";
34
import type { OutputFormat } from "./types.ts";
45

56
/** Resolve a date-like value to a `Date`, or `null` if invalid/missing. */
@@ -95,7 +96,7 @@ export function formatTable(
9596

9697
// text: borderless aligned columns with bold headers
9798
const table = new Table({
98-
head: headers.map((h) => chalk.bold(h)),
99+
head: headers.map((h) => bunny.bold(h)),
99100
chars: {
100101
top: "",
101102
"top-mid": "",

0 commit comments

Comments
 (0)