25 lines
720 B
TypeScript
25 lines
720 B
TypeScript
export const SETUP_TOKEN_COMMAND = "python -m app.container_bootstrap setup-token";
|
|
|
|
type ClipboardWriter = Pick<Clipboard, "writeText">;
|
|
type CommandField = Pick<HTMLTextAreaElement, "focus" | "select">;
|
|
|
|
export async function copySetupTokenCommand(
|
|
clipboard: ClipboardWriter | undefined,
|
|
commandField: CommandField | null,
|
|
): Promise<"copied" | "selected" | "manual"> {
|
|
try {
|
|
if (clipboard?.writeText) {
|
|
await clipboard.writeText(SETUP_TOKEN_COMMAND);
|
|
return "copied";
|
|
}
|
|
} catch {
|
|
// Clipboard access may be unavailable on LAN HTTP or denied by the browser.
|
|
}
|
|
if (commandField) {
|
|
commandField.focus();
|
|
commandField.select();
|
|
return "selected";
|
|
}
|
|
return "manual";
|
|
}
|