refactor(ui): update menu, selector for TTY detection; thin dispatcher
- Update menu.ts and selector.ts to use isStdinTTY() and function-based terminal colors - Refactor index.ts from 995-line monolith to ~270-line dispatcher that registers all commands via the CLI parser and delegates to modules - Add initTTY() call at startup for correct pipe/TTY detection - Interactive menu expanded to include new commands (explain, review, changelog, suggest, amend)
This commit is contained in:
+21
-21
@@ -1,26 +1,26 @@
|
||||
export async function copyToClipboard(text: string): Promise<boolean> {
|
||||
const commands: string[][] = [];
|
||||
const commands: string[][] = [];
|
||||
|
||||
if (process.platform === "darwin") {
|
||||
commands.push(["pbcopy"]);
|
||||
} else if (process.platform === "linux") {
|
||||
commands.push(["xclip", "-selection", "clipboard"]);
|
||||
commands.push(["xsel", "--clipboard", "--input"]);
|
||||
}
|
||||
if (process.platform === "darwin") {
|
||||
commands.push(["pbcopy"]);
|
||||
} else if (process.platform === "linux") {
|
||||
commands.push(["xclip", "-selection", "clipboard"]);
|
||||
commands.push(["xsel", "--clipboard", "--input"]);
|
||||
}
|
||||
|
||||
for (const cmd of commands) {
|
||||
try {
|
||||
const proc = Bun.spawn(cmd, {
|
||||
stdin: "pipe",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
});
|
||||
proc.stdin.write(text);
|
||||
proc.stdin.end();
|
||||
const exitCode = await proc.exited;
|
||||
if (exitCode === 0) return true;
|
||||
} catch {}
|
||||
}
|
||||
for (const cmd of commands) {
|
||||
try {
|
||||
const proc = Bun.spawn(cmd, {
|
||||
stdin: "pipe",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
});
|
||||
proc.stdin.write(text);
|
||||
proc.stdin.end();
|
||||
const exitCode = await proc.exited;
|
||||
if (exitCode === 0) return true;
|
||||
} catch {}
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user