-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
select.mjs
69 lines (64 loc) · 1.63 KB
/
select.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
66
67
68
69
import * as url from 'node:url';
import { select, Separator } from '@inquirer/prompts';
const demo = async () => {
let answer;
answer = await select({
message: 'Select a package manager',
choices: [
{
name: 'npm',
value: 'npm',
description: 'npm is the most popular package manager',
},
{ name: 'yarn', value: 'yarn', description: 'yarn is an awesome package manager' },
new Separator(),
{ name: 'jspm', value: 'jspm', disabled: true },
{
name: 'pnpm',
value: 'pnpm',
disabled: '(pnpm is not available)',
},
],
});
console.log('Answer:', answer);
answer = await select({
message: 'Select your favorite letter',
choices: [
new Separator('== Alphabet (choices cycle as you scroll through) =='),
{ value: 'A' },
{ value: 'B' },
{ value: 'C' },
{ value: 'D' },
{ value: 'E' },
{ value: 'F' },
{ value: 'G' },
{ value: 'H' },
{ value: 'I' },
{ value: 'J' },
{ value: 'K' },
{ value: 'L' },
{ value: 'M' },
{ value: 'N' },
{ value: 'O', description: 'Letter O, not number 0' },
{ 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;