@jyeontu/console-input

1.0.4 • Public • Published

consoleInput

配置说明

config = [
    {
        name:'参数名',
        tip:'输入时提示',
        configTip:'确认信息提示 ',
        defaultVal:'默认值'
    }
]
  • name

参数名称,后面获取值的时候的作为可以返回,具体如下:

{
    参数名1: 控制台输入值1,
    参数名2: 控制台输入值2,
    .
    .
    .
    参数名n: 控制台输入值n,
}
  • tip

控制台输入提示,如下图

image.png

  • configTip

确认信息时的提示,如下图

image.png

  • defaultVal

设置默认值,控制台输入为空时使用默认值替代,如下图

image.png

example

1、安装依赖

npm install @jyeontu/console-input

2、在代码中引用

  • 引入依赖
const ConsoleInput = require('@jyeontu/console-input');
  • 配置信息
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);
});

完整示例代码

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 }
});

Readme

Keywords

Package Sidebar

Install

npm i @jyeontu/console-input

Weekly Downloads

0

Version

1.0.4

License

ISC

Unpacked Size

7.47 kB

Total Files

5

Last publish

Collaborators

  • jyeontu