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

cli-list

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-list

Break CLI lists into arrays

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
172K
decreased by-17.71%
Maintainers
0
Weekly downloads
 
Created
Source

cli-list

Break CLI lists into arrays

build status downloads

Given a "CLI list" like so:

foo bar, baz --qux, oof

We can expect process.argv to be something such as:

['foo', 'bar,', 'baz', '--qux,', 'oof']

If we run this through the cli-list function we can split it into sub-arrays where the commas are:

[['foo', 'bar'], ['baz', '--qux'], ['oof']]

Theses arrays maintain the process.argv style, so they can be used in parity with things like minimist.

Installation

$ npm install --save cli-list

Usage

var list = require('cli-list');
var opts = list(process.argv.slice(2));

ES6 + Minimist:

import list from 'cli-list';
import minimist from 'minimist';
const opts = list(process.argv.slice(2)).map(item => minimist(item));

Examples

Given:

$ test foo --bar, baz, --qux

Expect:

[['foo', '--bar'], ['baz'], ['--qux']]

Credits

jamen
Jamen Marzonie

FAQs

Package last updated on 06 Dec 2024

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