Socket
Socket
Sign inDemoInstall

argumentate

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    argumentate

A simple argv parser (like so many others)


Version published
Weekly downloads
3
decreased by-40%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Argumentate

A very simple argv parser

Installation

npm install argumentate

Usage

// make executable (not required, but needed if you are building a cli with a bin file (remember to put bin in your package.json!))
#!/usr/bin/env node

// import argumentate
let argumentate = require('argumentate');

// slice to remove path args
let { options, variables } = argumentate({
	args: process.argv.slice(2),
	mapping: {
		c: 'config',
		p: {
			key: 'port',
			help: 'Port to use when launching this command'
		}
	},
	config: {
		name: 'My CLI',
		command: 'invoke-like-this'
	}
);

// be happy

Mappings

 const { options, variables } = argumentate({
 	args: ['start', '-p=8080', '-c', './myconfig.json'],
 	mapping: {
	 	c: 'config',
		p: {
			key: 'port',
			help: 'Port to use when launching this command'
		}
 	}
 );

// returns
{ 
	options: {
		port: '8080',
		config: './myconfig.json'
	},
	variables: ['start']
}

Keywords

FAQs

Last updated on 27 Mar 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc