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

cli-defaults

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

cli-defaults

Any cli tool should provide these options

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

cli-defaults

Add default answers to your command line script.

This module will provide these options by default:

  • help
  • version

Demo

Default commands:

% ./example.js
% ./example.js --version
0.1.0
% ./example.js --help
Any cli tool should provide these options
usage: cli-defaults [options]

 --help prints this message
 --version prints package version

You can add custom commands:

% ./example.js --ping
pong
% ./example.js --echo 'hello world'
hello world
% ./example.js --double 42
84

Install

% npm install --save cli-defaults

Usage

const argv = require('minimist')(process.argv.slice(2))
const CLI = require('cli-defaults')

const c = new CLI({
  ping: () => console.log('pong')
})

c.answer(argv)

provides default commands (help, version) + one custom 'ping' command

For more details check example.js and test/index.test.js

Keywords

FAQs

Package last updated on 03 Oct 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