-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
checkbox.mjs
65 lines (60 loc) · 1.49 KB
/
checkbox.mjs
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
65
import * as url from 'node:url';
import { checkbox, Separator } from '@inquirer/prompts';
const demo = async () => {
let answer;
answer = await checkbox({
message: 'Select a package manager',
choices: [
{ name: 'npm', value: 'npm' },
{ name: 'yarn', value: 'yarn' },
new Separator(),
{ name: 'jspm', value: 'jspm', disabled: true },
{
name: 'pnpm',
value: 'pnpm',
disabled: '(pnpm is not available)',
},
],
});
console.log('Answer:', answer);
answer = await checkbox({
message: 'Select your favorite letters',
choices: [
new Separator('== Alphabet (choices cycle as you scroll through) =='),
{ value: 'A', checked: true },
{ value: 'B' },
{ value: 'C', checked: true },
{ value: 'D' },
{ value: 'E' },
{ value: 'F' },
{ value: 'G' },
{ value: 'H' },
{ value: 'I' },
{ value: 'J' },
{ value: 'K' },
{ value: 'L' },
{ value: 'M' },
{ value: 'N' },
{ value: 'O' },
{ value: 'P' },
{ value: 'Q' },
{ value: 'R' },
{ value: 'S' },
{ value: 'T' },
{ value: 'U' },
{ value: 'V' },
{ value: 'W' },
{ value: 'X' },
{ value: 'Y' },
{ value: 'Z' },
],
});
console.log('Answer:', answer);
};
if (import.meta.url.startsWith('file:')) {
const modulePath = url.fileURLToPath(import.meta.url);
if (process.argv[1] === modulePath) {
demo();
}
}
export default demo;