[READ-ONLY] Mirror of https://github.com/bombshell-dev/clack. Effortlessly build beautiful command-line apps bomb.sh/docs/clack/basics/getting-started
cli command-line command-line-app node prompt prompts
Something went wrong. Try again.
TypeScript
12345678910111213141516171819202122232425262728293031import * as p from '@clack/prompts';import color from 'picocolors';
async function main() { const defaultPath = 'my-project';
const result = await p.text({ message: 'Enter the directory to bootstrap the project', placeholder: ` (hit Enter to use '${defaultPath}')`, defaultValue: defaultPath, validate: (value) => { if (!value) { return 'Directory is required'; } if (value.includes(' ')) { return 'Directory cannot contain spaces'; } return undefined; }, });
if (p.isCancel(result)) { p.cancel('Operation cancelled.'); process.exit(0); }
p.outro(`Let's bootstrap the project in ${color.cyan(result)}`);}
main().catch(console.error);