[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
5

Configure Feed

Select the types of activity you want to include in your feed.

feat(@clack/prompts): builder example

Bruno Rocha (Aug 10, 2023, 6:39 PM -0300) 20c19d9d 07e91d2b

+61 -1
+59
examples/builder.ts
··· 1 + import * as p from '@clack/prompts'; 2 + 3 + (async () => { 4 + const results = await p 5 + .builder() 6 + .add('path', () => 7 + p.text({ 8 + message: 'Where should we create your project?', 9 + placeholder: './sparkling-solid', 10 + validate: (value) => { 11 + if (!value) return 'Please enter a path.'; 12 + if (value[0] !== '.') return 'Please enter a relative path.'; 13 + }, 14 + }) 15 + ) 16 + .add('password', () => 17 + p.password({ 18 + message: 'Provide a password', 19 + validate: (value) => { 20 + if (!value) return 'Please enter a password.'; 21 + if (value.length < 5) return 'Password should have at least 5 characters.'; 22 + }, 23 + }) 24 + ) 25 + .add('type', ({ results }) => 26 + p.select({ 27 + message: `Pick a project type within "${results.path}"`, 28 + initialValue: 'ts', 29 + maxItems: 5, 30 + options: [ 31 + { value: 'ts', label: 'TypeScript' }, 32 + { value: 'js', label: 'JavaScript' }, 33 + { value: 'rust', label: 'Rust' }, 34 + { value: 'go', label: 'Go' }, 35 + { value: 'python', label: 'Python' }, 36 + { value: 'coffee', label: 'CoffeeScript', hint: 'oh no' }, 37 + ], 38 + }) 39 + ) 40 + .add('tools', () => 41 + p.multiselect({ 42 + message: 'Select additional tools.', 43 + initialValues: ['prettier', 'eslint'], 44 + options: [ 45 + { value: 'prettier', label: 'Prettier', hint: 'recommended' }, 46 + { value: 'eslint', label: 'ESLint', hint: 'recommended' }, 47 + { value: 'stylelint', label: 'Stylelint' }, 48 + { value: 'gh-action', label: 'GitHub Action' }, 49 + ], 50 + }) 51 + ) 52 + .add('install', ({ results }) => 53 + p.confirm({ 54 + message: 'Install dependencies?', 55 + initialValue: false, 56 + }) 57 + ) 58 + .run(); 59 + })();
+2 -1
examples/package.json
··· 11 11 "scripts": { 12 12 "basic": "jiti ./basic.ts", 13 13 "spinner": "jiti ./spinner.ts", 14 - "changesets": "jiti ./changesets.ts" 14 + "changesets": "jiti ./changesets.ts", 15 + "builder": "jiti ./builder.ts" 15 16 }, 16 17 "devDependencies": { 17 18 "jiti": "^1.17.0"