Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

argscan

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argscan

A simple CLI argument parser optimized for daplie style tools.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

argscan

This is a very simple CLI argument parser optimized for Daplie style.

The main export is a scan function that expects a process.argv style array and returns you processed information such as the command, flags, and positional args.

Install

$ npm install --save argscan

Usage

// Pass the argv to the scan function to get parsed parts
var { command, flags, args } = require('argscan')(process.argv)

// Do logic using command string, flags map, and args list
switch (command) {
  case 'greet':
    if (flags.loudly) { console.log('HELLO ') }
    else { console.log ('hi') }
    break
  ...
}

Style

Daplie style arg parsing means a few assumptions.

Command

First you're expected to have several commands with optional : namespacing. For example yourprogram action:subaction where action:subaction is the command.

Also both long and short flags are supported. Long flags are expected to always look like --someFlag or --key=value. Short flags are single-character flags. You can have as many as you want on a single position. For example -tim is the same as -t -i -m. Both will generate a flags map of { t: true, i: true, m: true }.

Keywords

FAQs

Package last updated on 29 Apr 2017

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