-
Notifications
You must be signed in to change notification settings - Fork 0
/
1-main.ts
64 lines (60 loc) · 1.7 KB
/
1-main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// 1-main-example.ts: An advanced example of a CLI application with a beautiful UI config. This example
// demonstrates all possible prompt components. Everything is divided into separate files for clarity.
import {
askDir,
doSomeFunStuff,
showAnimatedText,
showAnykeyPrompt,
showConfirmPrompt,
showDatePrompt,
showEndPrompt,
showNumMultiselectPrompt,
showNextStepsPrompt,
showNumberPrompt,
showNumSelectPrompt,
showPasswordPrompt,
showResults,
showStartPrompt,
showInputPrompt,
showSelectPrompt,
showMultiselectPrompt,
showProgressBar,
showTogglePrompt,
} from "@/src/prompts.js";
import { type UserInput } from "@/src/schema.js";
import { errorHandler } from "~/utils/errors.js";
export async function detailedExample() {
await showStartPrompt();
await showAnykeyPrompt("privacy");
const username = await showInputPrompt();
const dir = await askDir(username);
const age = await showNumberPrompt();
const password = await showPasswordPrompt();
const birthday = await showDatePrompt();
const lang = await showSelectPrompt();
const langs = await showMultiselectPrompt();
const color = await showNumSelectPrompt();
const features = await showNumMultiselectPrompt();
const toggle = await showTogglePrompt();
const spinner = await showConfirmPrompt(username);
const userInput = {
username,
dir,
age,
lang,
color,
password,
birthday,
langs,
features,
spinner,
toggle,
} satisfies UserInput;
await showProgressBar();
await showResults(userInput);
await doSomeFunStuff(userInput);
await showNextStepsPrompt();
await showAnimatedText();
await showEndPrompt();
}
await detailedExample().catch((error) => errorHandler(error));