Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TopCli/stdin
Node.js light ⚡, interactive and elegant input crafted for REPL experience.
https://github.com/TopCli/stdin
cli input interactive repl stdin tty
Last synced: 23 days ago
JSON representation
Node.js light ⚡, interactive and elegant input crafted for REPL experience.
- Host: GitHub
- URL: https://github.com/TopCli/stdin
- Owner: TopCli
- License: mit
- Created: 2019-09-08T19:13:46.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-01T01:11:42.000Z (11 months ago)
- Last Synced: 2024-11-07T00:47:28.283Z (about 1 month ago)
- Topics: cli, input, interactive, repl, stdin, tty
- Language: JavaScript
- Homepage:
- Size: 206 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-crafted-nodejs - @slimio/stdin - Node.js light, interactive and elegant input crafted for REPL experience. (Packages / CLI (TTY etc..))
README
# Stdin
![version](https://img.shields.io/badge/dynamic/json.svg?style=for-the-badge&url=https://raw.githubusercontent.com/TopCli/stdin/master/package.json&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg?style=for-the-badge)](https://github.com/TopCli/stdin/commit-activity)
[![mit](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](https://github.com/TopCli/stdin/blob/master/LICENSE)
[![OpenSSF
Scorecard](https://api.securityscorecards.dev/projects/github.com/TopCli/stdin/badge?style=for-the-badge)](https://api.securityscorecards.dev/projects/github.com/TopCli/stdin)
![build](https://img.shields.io/github/actions/workflow/status/TopCli/stdin/node.js.yml?style=for-the-badge)Node.js light and interactive standard input (stdin) crafted for REPL (like) experience (with auto-completion and history). Under the hood it use `process.stdin` and TTY Stream with the raw mode enabled to catch key by key.
Demo with the SlimIO CLI
## Requirements
- [Node.js](https://nodejs.org/en/) v14 or higher## Getting Started
This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).
```bash
$ npm i @topcli/stdin
# or
$ yarn add @topcli/stdin
```## Usage example
```js
import stdin from "@topcli/stdin";const data = await stdin("Question title > ", {
history: ["command in history 1", "command in history 2"],
autocomplete: [
"events",
"events.get_info"
]
});
console.log(`input data: ${data}`);
```> 👀 the reference to the history array is keeped. So if you want to achieve a while of input, think to declare a top array history that will be used by all inputs.
## API
### stdin(query: null | string, options?: StdinOptions): Promise< string >
Query paramaters can be set to `null` to disable the title. Options is described by the following TypeScript interface:```ts
interface StdinOptions {
history?: string[];
autocomplete?: string[];
}
```history and autocomplete are optional. There is no thing as a cache or limitation for history (you have to implement that kind of stuff yourself with [cacache](https://www.npmjs.com/package/cacache)).
## Contributors ✨
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Gentilhomme
💻 📖 👀 🛡️ 🐛
Alexandre Malaj
💻 📖
PierreDemailly
💻 ⚠️
## License
MIT