textui/mod.ts

29 lines
693 B
TypeScript
Raw Normal View History

2021-05-19 13:00:52 +00:00
import { AnsiTerminalDisplay } from "./ansi.ts";
2021-06-28 18:21:32 +00:00
import { UIConfig } from "./config.ts";
import { Display } from "./display.ts";
import { TextUI } from "./ui.ts";
2021-05-19 13:00:52 +00:00
export { TextUI } from "./ui.ts";
2021-06-28 18:21:32 +00:00
export const UI_DISPLAY_TYPES = {
autodetect: undefined,
ansi: AnsiTerminalDisplay,
dummy: Display,
} as const;
export async function createTextUI(
config: Partial<UIConfig>,
display_type: keyof typeof UI_DISPLAY_TYPES = "autodetect",
): Promise<TextUI> {
if (display_type == "autodetect") {
// TODO detect platform
display_type = "ansi";
}
var display = new UI_DISPLAY_TYPES[display_type]();
var ui = new TextUI(display, config);
await ui.init();
2021-06-24 23:09:05 +00:00
2021-05-19 13:00:52 +00:00
return ui;
}