Socket
Book a DemoInstallSign in
Socket

@jyeontu/console-input

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jyeontu/console-input

node控制台输入配置

1.0.4
latest
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

readline

FAQs

Package last updated on 26 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.