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

clinical

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clinical

A minimum-viable arguments parser in ~90 LOC with zero dependencies

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

clinical npm Version build

A minimum-viable arguments parser in ~90 LOC with zero dependencies

Features

  • Casts values to the appropriate JavaScript primitive type
  • Converts option keys to camelCase
  • Throws on duplicated options
  • Stops parsing options after --
  • Prints the supplied version on --version or -v
  • Prints the supplied help message on --help or -h

Example

$ npm install --save clinical
#!/usr/bin/env node

import clinical from 'clinical'

try {
  const result = clinical('1.0.0', 'my help message')
  console.log(result)
} catch (error) {
  console.error(error.message)
  process.exit(1)
}
$ my-cli --foo --bar 42 -x=y -- baz null
{
  options: { foo: true, bar: 42, x: 'y' },
  positionals: [ 'baz', null ]
}
$ my-cli --version
1.0.0
$ my-cli --help
my help message

API

import clinical from 'clinical'

const result = clinical(version, helpMessage [, args = process.argv.slice(2)])

  • version (string) – Required. Writes this string to stdout on encountering the --version or -v flag, then exits the process.
  • helpMessage (string) – Required. Writes this string to stdout on encountering the --help or -h flag, then exits the process.
  • args (Array<string>) – Optional. The arguments to be parsed. Defaults to process.argv.slice(2).

The returned result object has the following keys:

  • positionals (Array<boolean | null | number | string>)
  • options ({ [key: string]: boolean | null | number | string })

Installation

$ npm install --save clinical

License

MIT

Keywords

FAQs

Package last updated on 15 Nov 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

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