# @jyeontu/console-input

> node控制台输入配置

Latest version **1.0.4** (published 2022-07-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install @jyeontu/console-input
pnpm add @jyeontu/console-input
yarn add @jyeontu/console-input
bun add @jyeontu/console-input
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2022-07-26 |
| First published | 2022-07-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | jyeontu |
| Maintainers | jyeontu |
| Keywords | readline, node |

## Links

- npm: https://www.npmjs.com/package/@jyeontu/console-input
- npm.io page: https://npm.io/package/@jyeontu/console-input

## Dependencies (1)

- [readline](https://npm.io/package/readline.md) ^1.3.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2022-07-26
- 1.0.3 — 2022-07-26
- 1.0.2 — 2022-07-26
- 1.0.1 — 2022-07-25
- 1.0.0 — 2022-07-25

## README

## consoleInput
### 配置说明
```javascript
config = [
    {
        name:'参数名',
        tip:'输入时提示',
        configTip:'确认信息提示 ',
        defaultVal:'默认值'
    }
]
```
- name
> 参数名称，后面获取值的时候的作为可以返回，具体如下：
```javascript
{
    参数名1: 控制台输入值1,
    参数名2: 控制台输入值2,
    .
    .
    .
    参数名n: 控制台输入值n,
}
```
- tip
> 控制台输入提示，如下图

![image.png](https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/65eaa928dd754394bb057eed18a3757a~tplv-k3u1fbpfcp-watermark.image?)

- configTip
> 确认信息时的提示，如下图

![image.png](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/6dfe8afe7a384c0187631d0871eeaa9d~tplv-k3u1fbpfcp-watermark.image?)

- defaultVal
> 设置默认值，控制台输入为空时使用默认值替代，如下图

![image.png](https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/dc804d1fcaf14586b3f9961903d37c2d~tplv-k3u1fbpfcp-watermark.image?)

### example
#### 1、安装依赖
```shell
npm install @jyeontu/console-input
```
#### 2、在代码中引用
- 引入依赖
```javascript
const ConsoleInput = require('@jyeontu/console-input');
```
- 配置信息
```javascript
const config = [
    {
        name:'videoPath',
        tip:'请输入视频路径(如./video/1.mp4):',
        configTip:'视频路径: ',
        defaultVal:'./video/1.mp4'
    },
    {
        name:'saveFilePath',
        tip:'请输入截图保存路径(如./img/): ',
        configTip:'截图保存路径:',
        defaultVal:'./img/'
    },
    {
        name:'cutNums',
        tip:'请输入需要截取图片数量(如30),注意:数量应该小于视频时间秒数: ',
        configTip:'截取图片数量:',
        defaultVal:30
    }
];
```
- 控制台输入并返回输入信息
```javascript
const test = new ConsoleInput(config);
let res = test.askInput();
res.then(res=>{
    console.log(res);
});
```
#### 完整示例代码
```javascript
const ConsoleInput = require('./consoleInput');
const config = [
    {
        name:'videoPath',
        tip:'请输入视频路径(如./video/1.mp4):',
        configTip:'视频路径: ',
        defaultVal:'./video/1.mp4'
    },
    {
        name:'saveFilePath',
        tip:'请输入截图保存路径(如./img/): ',
        configTip:'截图保存路径:',
        defaultVal:'./img/'
    },
    {
        name:'cutNums',
        tip:'请输入需要截取图片数量(如30),注意:数量应该小于视频时间秒数: ',
        configTip:'截取图片数量:',
        defaultVal:30
    }
];
const test = new ConsoleInput(config);
let res = test.askInput();
res.then(res=>{
    console.log(res);
    //{ videoPath: './video/1.mp4', saveFilePath: './img/', cutNums: 30 }
});
```

---
_Source: https://npm.io/package/@jyeontu/console-input · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
