Socket
Book a DemoInstallSign in
Socket

commandments

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commandments

Parse argument commands/options from code comments using esprima and minimist.

Source
npmnpm
Version
0.2.4
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

commandments NPM version Build Status

Parse argument commands/options from code comments using esprima and minimist.

(TOC generated by verb)

Install

Install with npm

$ npm i commandments --save

Usage

var commandments = require('commandments');

Example

Given you have a file named app.js with some code comments (both block and line comments will work):

// abc: apple kiwi grapefruit */
function foo(str) {
  return str;
}

function bar(str) {
  /* xyz: --exclude=cranberry */
  return str;
}

Pass keyword(s) to identify comments to parse, and the string with comments to parse.

var fs = require('fs');
var str = fs.readFileSync('lib/app.js', 'utf8');

// commandments([keywords], str);
var args = commandments(['abc', 'xyz'], str);

Results in:

{ abc: { _: [ 'apple', 'kiwi', 'grapefruit' ] },
  xyz: { _: [], exclude: 'cranberry' } }

API

commandments

Pass the keywords to use for identifying comments that should be parsed.

Heads up!:

  • a keyword must be the first thing in a comment, and
  • a "commandments comment" should only have arguments to be parsed.

Example:

Params

  • keywords {String|Array}: Keyword(s) to identify comments to parse.
  • str {String}: A string of valid javascript with comments to parse.
  • options {Object}: Options to pass to [minimist]
  • returns {Object}: Object of parsed arguments.

Example

commandments([keywords], str, opts={});

lint-deps: CLI tool that tells you when dependencies are missing from package.json and offers you a… more | homepage

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.

This file was generated by verb on December 20, 2015.

Keywords

args

FAQs

Package last updated on 20 Dec 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