clt

cltags

Lightweight library for parsing process.argv

Showing:

Popularity

Downloads/wk

5

Maintenance

No Maintenance Data Available

Package

Dependencies

0

Size (min+gzip)

0.5KB

License

Type Definitions

Tree-Shakeable

No?

Categories

Readme

ClTags

A Lightweight Node.JS module for parsing process.argv

Code Example

var tags = require("cltags");
var options = tags.parse(process.argv);

Thats really all their is to it, so for example if you ran your script with:

node script_name search --recursive --filetype="js" demo search query

You would get back from the tags.parse command an object that looks like:

{
  command: "search",
  filetype: "js",
  recursive: true,
  query: "demo search query"
}

Other features

  • Defaults - the second parameter is an optional list of defaults which will get returned in the object unless overridden
  • Short Formed Tags - the third parameter is a list of replacements for short tags

All together it would look something like the following:

var tags = require("cltags");

var defaults = {
  depth: 2,
  recursive: false
}

var replacements = {
  d: "depth",
  r: "recursive"
}

var options = tags.parse(process.argv, defaults, replacements);

You can then run something like:

script_name -r

and get back an object like:

{
  command: "",
  query: "",
  depth: 2,
  recursive: true
}

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100