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

minimisted

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minimisted

Handy wrapper of `minimist`

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
430K
increased by0.36%
Maintainers
1
Weekly downloads
 
Created
Source

minimisted v1.1.0

Circle CI codecov js-standard-style

Handy wrapper of minimist

minimist is a nice handy library for parsing the command line options, but its interface is not such nice and a bit too tedious if you use it a number of times. This library gives you an interface to use minimist a bit more declarative way.

Install

npm install minimisted

Usage

You can write your cli like the following:

// Your cli's entry point
const main = (argv) => {
}

require('minimisted')(main)

where argv is the parsed command line options by minimist, which is exactly the same as minimist(process.argv.slice(2)).

Using object destructuring syntax, you can write it like the following:

/**
 * @param {boolean} help Shows help message if true
 * @param {boolean} version Shows the version if true
 * ...
 * @param {string[]} _ The parameters
 */
const main = ({help, version, _}) => {
}

require('minimisted')(main)

You can forget about what minimist does and you can only get what you want i.e. the parsed argv object.

Exit code

If your main function returns a number other than 0, it is used as the return code of the cli.

sample-cli.js

const main = ({foo}) => {
  if (foo) {
    return 1
  }
}

requrie('minimisted')(main)

With the above example, node sample-cli.js exits with 0, which means the success, andnode sample.js --foo exits with 1, which means the failure.

License

MIT

Keywords

FAQs

Package last updated on 11 Aug 2016

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