All Projects → 75lb → Command Line Args

75lb / Command Line Args

Licence: mit
A mature, feature-complete library to parse command-line options.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Command Line Args

Argagg
A simple C++11 command line argument parser
Stars: ✭ 180 (-65.71%)
Mutual labels:  command-line-parser, option-parser
command-line-commands
Add a git-like command interface to your app.
Stars: ✭ 40 (-92.38%)
Mutual labels:  option-parser, command-line-parser
Catchart
Pipe something from command line to a chart in the browser
Stars: ✭ 27 (-94.86%)
Mutual labels:  npm-package, nodejs-modules
Clikt
Multiplatform command line interface parsing for Kotlin
Stars: ✭ 1,658 (+215.81%)
Mutual labels:  command-line-parser, option-parser
declarative-parser
Modern, declarative argument parser for Python 3.6+
Stars: ✭ 31 (-94.1%)
Mutual labels:  option-parser, command-line-parser
Kotlin Argparser
Easy to use and concise yet powerful and robust command line argument parsing for Kotlin
Stars: ✭ 431 (-17.9%)
Mutual labels:  command-line-parser, option-parser
Inspirational Quotes
💡 A simple NPM Package which returns random Inspirational Quotes. Get your daily quote and stay motivated! ✌️ 🌸
Stars: ✭ 150 (-71.43%)
Mutual labels:  npm-package, nodejs-modules
Programoptions.hxx
Single-header program options parsing library for C++11
Stars: ✭ 112 (-78.67%)
Mutual labels:  command-line-parser, option-parser
CmdLine2
Command line argument parser (C++14)
Stars: ✭ 18 (-96.57%)
Mutual labels:  option-parser, command-line-parser
arcscord
A Discord library written in typescript
Stars: ✭ 18 (-96.57%)
Mutual labels:  npm-package, nodejs-modules
Awesome Npm Packages
🚀 A collection of awesome npm packages for Noders.
Stars: ✭ 69 (-86.86%)
Mutual labels:  npm-package, nodejs-modules
option-parser
A Lightweight, header-only CLI option parser for C++
Stars: ✭ 16 (-96.95%)
Mutual labels:  option-parser, command-line-parser
argparser
Simple command-line parser for C/C++ programs
Stars: ✭ 50 (-90.48%)
Mutual labels:  option-parser, command-line-parser
dropt
dropt is yet another C library for parsing command-line options.
Stars: ✭ 39 (-92.57%)
Mutual labels:  option-parser, command-line-parser
A To Z List Of Useful Node.js Modules
Collection of most awesome node modules that will extend the capability of your node.js application.
Stars: ✭ 315 (-40%)
Mutual labels:  npm-package, nodejs-modules
Trex
Package Manager for deno 🦕
Stars: ✭ 433 (-17.52%)
Mutual labels:  npm-package
Ignite Ui
Ignite UI by Infragistics
Stars: ✭ 468 (-10.86%)
Mutual labels:  npm-package
Npm Run All
A CLI tool to run multiple npm-scripts in parallel or sequential.
Stars: ✭ 4,496 (+756.38%)
Mutual labels:  npm-package
Strip Json Comments
Strip comments from JSON. Lets you use comments in your JSON files!
Stars: ✭ 492 (-6.29%)
Mutual labels:  npm-package
Tfjs Yolo Tiny
In-Browser Object Detection using Tiny YOLO on Tensorflow.js
Stars: ✭ 465 (-11.43%)
Mutual labels:  npm-package

view on npm npm module downloads Gihub repo dependents Gihub package dependents Build Status Coverage Status js-standard-style

Upgraders, please read the release notes

command-line-args

A mature, feature-complete library to parse command-line options.

Synopsis

You can set options using the main notation standards (learn more). These commands are all equivalent, setting the same values:

$ example --verbose --timeout=1000 --src one.js --src two.js
$ example --verbose --timeout 1000 --src one.js two.js
$ example -vt 1000 --src one.js two.js
$ example -vt 1000 one.js two.js

To access the values, first create a list of option definitions describing the options your application accepts. The type property is a setter function (the value supplied is passed through this), giving you full control over the value received.

const optionDefinitions = [
  { name: 'verbose', alias: 'v', type: Boolean },
  { name: 'src', type: String, multiple: true, defaultOption: true },
  { name: 'timeout', alias: 't', type: Number }
]

Next, parse the options using commandLineArgs():

const commandLineArgs = require('command-line-args')
const options = commandLineArgs(optionDefinitions)

options now looks like this:

{
  src: [
    'one.js',
    'two.js'
  ],
  verbose: true,
  timeout: 1000
}

Advanced usage

Beside the above typical usage, you can configure command-line-args to accept more advanced syntax forms.

  • Command-based syntax (git style) in the form:

    $ executable <command> [options]
    

    For example.

    $ git commit --squash -m "This is my commit message"
    
  • Command and sub-command syntax (docker style) in the form:

    $ executable <command> [options] <sub-command> [options]
    

    For example.

    $ docker run --detached --image centos bash -c yum install -y httpd
    

Usage guide generation

A usage guide (typically printed when --help is set) can be generated using command-line-usage. See the examples below and read the documentation for instructions how to create them.

A typical usage guide example.

usage

The polymer-cli usage guide is a good real-life example.

usage

Further Reading

There is plenty more to learn, please see the wiki for examples and documentation.

Install

$ npm install command-line-args --save

© 2014-20 Lloyd Brookes <[email protected]>.

Tested by test-runner. Documented by jsdoc-to-markdown.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].