Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/bombshell-dev/clack. Effortlessly build beautiful command-line apps bomb.sh/docs/clack/basics/getting-started
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364import * as p from '@clack/prompts';
(async () => { const results = await p .workflow() .step('name', () => p.text({ message: 'What is your package name?' })) .step('type', () => p.select({ message: `Pick a project type:`, initialValue: 'ts', maxItems: 5, options: [ { value: 'ts', label: 'TypeScript' }, { value: 'js', label: 'JavaScript' }, { value: 'rust', label: 'Rust' }, { value: 'go', label: 'Go' }, { value: 'python', label: 'Python' }, { value: 'coffee', label: 'CoffeeScript', hint: 'oh no' }, ], }) ) .step('install', () => p.confirm({ message: 'Install dependencies?', initialValue: false, }) ) .step('fork', ({ results }) => { if (results.install === true) { return p.workflow().step('package', () => p.select({ message: 'Pick a package manager:', initialValue: 'pnpm', options: [ { label: 'npm', value: 'npm', }, { label: 'yarn', value: 'yarn', }, { label: 'pnpm', value: 'pnpm', }, ], }) ).run(); } }) .run();
await p .workflow() .step('cancel', () => p.text({ message: 'Try cancel prompt (Ctrl + C):' })) .step('afterCancel', () => p.text({ message: 'This will not appear!' })) .onCancel(({ results }) => { p.cancel('Workflow canceled'); process.exit(0); }) .run();})();