MCPcopy Create free account
hub / github.com/bombshell-dev/clack / main

Function main

examples/basic/default-value.ts:4–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import color from 'picocolors';
3
4async function main() {
5 const defaultPath = 'my-project';
6
7 const result = await p.text({
8 message: 'Enter the directory to bootstrap the project',
9 placeholder: ` (hit Enter to use '${defaultPath}')`,
10 defaultValue: defaultPath,
11 validate: (value) => {
12 if (!value) {
13 return 'Directory is required';
14 }
15 if (value.includes(' ')) {
16 return 'Directory cannot contain spaces';
17 }
18 return undefined;
19 },
20 });
21
22 if (p.isCancel(result)) {
23 p.cancel('Operation cancelled.');
24 process.exit(0);
25 }
26
27 p.outro(`Let's bootstrap the project in ${color.cyan(result)}`);
28}
29
30main().catch(console.error);

Callers 1

default-value.tsFile · 0.70

Calls 1

cancelMethod · 0.80

Tested by

no test coverage detected