Add src/tools/cli with a CliFlow helper (boxed headers, labeled log lines) and a reset-password command stub wired to the prompt package. Runnable via 'bun run u:reset-password'; interactive flow to follow.
43 lines
1 KiB
TypeScript
43 lines
1 KiB
TypeScript
export class CliFlow {
|
|
protected moduleName: string;
|
|
|
|
constructor(moduleName: string) {
|
|
this.moduleName = moduleName;
|
|
}
|
|
|
|
/**
|
|
* showHeader
|
|
*/
|
|
public showHeader(title: string, subtitle?: string) {
|
|
const LENGTH = Math.max(title.length, subtitle?.length ?? 0) + 5;
|
|
|
|
// Chars: ╔═╗║╚═╝╬
|
|
|
|
// Draw the top border
|
|
let topStr = "╔";
|
|
for (let i = 0; i < LENGTH; i++) {
|
|
topStr += "═";
|
|
}
|
|
topStr += "╗";
|
|
console.log(topStr);
|
|
|
|
// Draw the title
|
|
console.log(`║ \x1B[33;1m${title}\x1B[0m ${"║".padStart(LENGTH - title.length - 1, " ")}`);
|
|
|
|
// Draw the subtitle
|
|
subtitle &&
|
|
console.log(`║ \x1B[2m${subtitle}\x1B[0m ${"║".padStart(LENGTH - subtitle.length - 1, " ")}`);
|
|
|
|
// Draw the bottom border
|
|
let btmStr = "╚";
|
|
for (let i = 0; i < LENGTH; i++) {
|
|
btmStr += "═";
|
|
}
|
|
btmStr += "╝";
|
|
console.log(btmStr + "\n");
|
|
}
|
|
|
|
log(...msg: string[]) {
|
|
console.log(`\t\x1B[33m[LOG]\x1B[0m ${msg.join(" ")}`);
|
|
}
|
|
}
|