https://github.com/wobsoriano/bun-promptx
Terminal prompt library for the Bun runtime
https://github.com/wobsoriano/bun-promptx
bun bunjs cli go prompt tui
Last synced: 3 days ago
JSON representation
Terminal prompt library for the Bun runtime
- Host: GitHub
- URL: https://github.com/wobsoriano/bun-promptx
- Owner: wobsoriano
- License: mit
- Created: 2022-07-19T21:57:45.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-19T03:54:01.000Z (over 1 year ago)
- Last Synced: 2025-03-13T05:35:03.699Z (about 1 month ago)
- Topics: bun, bunjs, cli, go, prompt, tui
- Language: Go
- Homepage:
- Size: 107 KB
- Stars: 112
- Watchers: 4
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-bun - bun-promptx - Terminal prompt library based on bubbles via bun:ffi. (Extensions / Utilities)
README
# bun-promptx
bun-promptx is a terminal prompt library based on [bubbles](https://github.com/mritd/bubbles) via `bun:ffi`.
## Install
```bash
bun add bun-promptx
```## Usage
### createSelection
The `createSelection` function lets you create a terminal single-selection list prompt. It provides the functions of page up and down and key movement, and supports custom rendering methods.
```js
import { createSelection } from 'bun-promptx'const result = createSelection([
{ text: 'feat', description: 'Introducing new features' },
{ text: 'fix', description: 'Bug fix' },
{ text: 'docs', description: 'Writing docs' },
{ text: 'style', description: 'Improving structure/format of the code' },
{ text: 'refactor', description: 'Refactoring code' },
{ text: 'test', description: 'Refactoring code' },
{ text: 'chore', description: 'When adding missing tests' },
{ text: 'perf', description: 'Improving performance' }
], {
headerText: 'Select Commit Type: ',
perPage: 5,
footerText: 'Footer here'
})console.log(result)
// { selectedIndex: 2, error: null }
```
### createPrompt
The `createPrompt` function is a terminal input prompt library. It provides CJK character support and standard terminal shortcut keys (such as ctrl+a, ctrl+e), password input echo and other functions.
```js
import { createPrompt } from 'bun-promptx'const username = createPrompt("Enter username: ")
// { value: "wobsoriano", error: null }const password = createPrompt("Enter password: ", {
echoMode: 'password'
})
// { value: "123456", error: null }
```
## License
MIT