@iohub/prompt
Version:
Interactive CLI prompts for selecting files, folders, and extensions using Inquirer, with beautiful formatting and logging
76 lines (56 loc) • 2.56 kB
Markdown
# @iohub/prompt
Interactive CLI prompts for file system operations
[](https://npmjs.org/package/@iohub/prompt)
[](http://packagequality.com/#?package=@iohub/prompt)
[](https://npmjs.org/package/@iohub/prompt)
[](https://npmjs.org/package/@iohub/prompt)
[](https://packagephobia.now.sh/result?p=@iohub/prompt)
[](https://github.com/hoyeungw/iohub)
[](https://npmjs.org/package/@iohub/prompt)
## Features
- Interactive file system selection with checkbox interface
- Efficient filtering by extensions, files, or folders
- Customizable page sizes for better UX
- Zero dependencies for core functionality
- Modern ES modules support
- TypeScript-ready
## Installation
```bash
# Using npm
npm install @iohub/prompt
# Using yarn
yarn add @iohub/prompt
# Using pnpm
pnpm add @iohub/prompt
```
## Usage
```js
import { promptExts, promptDocs, promptDirs } from '@iohub/prompt'
// Select files by extension
await promptExts('/path/to/source')
// Returns: string[] - Array of selected extensions
// Example: ['.js', '.ts', '.json']
// Select specific documents
await promptDocs('/path/to/source')
// Returns: string[] - Array of selected document paths
// Example: ['index.js', 'package.json']
// Select directories
await promptDirs('/path/to/source')
// Returns: string[] - Array of selected directory paths
// Example: ['src', 'test', 'dist']
```
## API
### promptExts(source: string)
Displays a checkbox prompt for selecting file extensions in the given source directory.
- Page size: 12 items
- Returns: Promise<string[]>
### promptDocs(source: string)
Displays a checkbox prompt for selecting documents in the given source directory.
- Page size: 24 items
- Returns: Promise<string[]>
### promptDirs(source: string)
Displays a checkbox prompt for selecting directories in the given source directory.
- Page size: 18 items
- Returns: Promise<string[]>
## License
[MIT](LICENSE) © Hoyeung Wong