New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

easy-arg

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy-arg

一个命令行解析模块

  • 0.1.1
  • unpublished
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Easy-Arg

用于方便的解析用户输入的命令行参数,

install

npm install --save easy-arg

API

// 引入并创建一个实例
const EasyArg = require('ease-arg');
const easyArg = new EasyArg('hello');

add

添加一个命令

// 添加init命令,用户输入在init后的参数会以数组的形式传入
// 只有add过的字符串,我们才认为是命令,否则一律认为是参数

easyArg.add('init', (input) => {
  console.log('input', input);
});

start

开始解析

// 参数为用户输入的所有命令以及参数组成的对象
easyArg.start((inputCommands) => {
  console.log(inputCommands);
});

事件

支持事件的方式触发

// 每当匹配到一个命令的时候,就会触发,接受命令的值以及命令的参数
easyArg.on('command', ({command, args}) => {
  if (command === '-b') {
    console.log(args);
  }
});

FAQs

Package last updated on 20 Jul 2018

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc