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

argler

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

argler

Parses a raw command line into arguments

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

argler

Argler is a simple module that parses a whole command line string into individual arguments that can be passed to modules (such as minimist) that expect process.argv-like argument array on input.

Examples

var argler = require('argler');

// 'one two three' -> [ 'one', 'two', 'three' ]
var args = argler('one two three');
console.dir(args);

// say -n 7 "this is a single argument"' -> [ 'say', '-n', '7', 'this is a single argument' ]
var args = argler('say -n 7 "this is a single argument"');
console.dir(args);

// 'say Hello\\ world!' -> [ 'say', 'Hello world!' ]
var args = argler('say Hello\\ world!');
console.dir(args);

Examples with minimist

var argler = require('argler');
var minimist = require('minimist');

// with minimist, you can do this:
var args = minimist(argler('get --retries 3 "document 1.txt"'));
console.dir(args);

// you might want to force all arguments (but not options) to be strings:
var args = minimist(argler('echo 1 2 3 4'), { string: ['_'] });
console.dir(args);

// parsing a command line into a command, arguments and options:
var args = argler('open sftp.nuane.com -P 22');
var cmd = args.shift();
var options = minimist(args, { string: ['_'] });
args = options._;
delete options._;
console.log(cmd);
console.dir(args);
console.dir(options);

Installing

$ npm install argler

Keywords

FAQs

Package last updated on 06 Oct 2015

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