New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

clipop

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

clipop

Utility to parse terminal input into a JSON object

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

clipop

Utility to parse terminal input into a JSON object

my-app --name "john doe" --is-admin

Options will be parsed like this:

{
  "name": "john doe",
  "is-admin": true
}

You can also use notations:

my-app --names.firstname joe --hobbies[0].name hockey 
{
  "names": {
    "firstname": "jo"
  },
  "hobbies": [
    {
      "name": "hockey"
    }
  ]
}

This utility only returns options and other arguments are ignored:

my-app connect --uri localhost --ssl 
{
  "uri": "localhost",
  "ssl": true
}

Usage

npm install clipop
import clipop from 'clipop'

const [,, ...params] = process.argv

const options = clipop(...params) // clipop accepts a spread array of strings

Value declarations

--foo     hello       # "hello"
--foo     22          # "22"
--foo     true        # "true"
--foo     false       # "false"
--foo     null        # "null"
--foo                 # true
--foo     ---22       # 22
--foo     ---true     # true
--foo     ---false    # false
--foo     ---null     # null

Typescript suppor

clipop<{ name: string }>(...params) // my-app --name joe

Keywords

cli

FAQs

Package last updated on 10 May 2020

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