-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.ts
55 lines (50 loc) · 1.2 KB
/
index.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
import { helpers, termost } from "termost";
import { name, version } from "../package.json" with { type: "json" };
type ProgramContext = {
input1: "singleOption1" | "singleOption2";
input2: ("multipleOption1" | "multipleOption2")[];
input3: boolean;
input4: string;
};
const program = termost<ProgramContext>({
name,
description: "Example to showcase the `input` API",
version,
});
program
.input({
key: "input1",
label: "What is your single choice?",
defaultValue: "singleOption2",
options: ["singleOption1", "singleOption2"],
type: "select",
})
.input({
key: "input2",
label: "What is your multiple choices?",
defaultValue: ["multipleOption2"],
options: ["multipleOption1", "multipleOption2"],
type: "multiselect",
})
.input({
key: "input3",
label: "Are you sure to skip next input?",
defaultValue: false,
type: "confirm",
})
.input({
key: "input4",
label: (context) =>
`Dynamic input label generated from a contextual value: ${context.input1}`,
defaultValue: "Empty input",
skip(context, argv) {
console.log(argv);
return Boolean(context.input3);
},
type: "text",
})
.task({
handler(context) {
helpers.message(JSON.stringify(context, null, 4));
},
});