https://github.com/devfans/argio
Super light-weighted nodejs command line argument parser.
https://github.com/devfans/argio
Last synced: 6 months ago
JSON representation
Super light-weighted nodejs command line argument parser.
- Host: GitHub
- URL: https://github.com/devfans/argio
- Owner: devfans
- Created: 2018-11-27T08:12:38.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-05T11:55:24.000Z (over 6 years ago)
- Last Synced: 2025-09-26T02:30:57.401Z (6 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# argio
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Build Status][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]
Nodejs command line arguments parser for parsing subcommands, value list and switches with super light-weight single function implementation.
## Installation
```
npm install argio
```
## Get Started
```
// command line
$ node app.js subcommand1 subcommand2 -p1 v1 v2 v3 --s1 -p2 v4
```
```
const argio = require('argio');
const parser = argio()
// Structure of parser
{ params:
{ subcommands:
[ '/usr/local/bin/node',
'/Users/stefan/git/argio/app.js',
'subcommand1',
'subcommand2' ],
p1: [ 'v1', 'v2', 'v3' ],
s1: true,
p2: [ 'v4' ]
},
get: [Function: get],
attributes: ['p1', 's1', 'p2'],
subcommand: 'subcommand1'
}
// check switches
parser.get('s1') // true
parser.get('s2') // undefined
// check single value
parser.get('p1') // v1
parser.get('p2') // v4
// check value list
parser.params.p1 // [ 'v1', 'v2', 'v3' ]
// check subcommand
parser.subcommand // subcommand1
// check subcommands
parser.params.subcommands // [...]
```
[npm-image]: https://img.shields.io/npm/v/argio.svg
[npm-url]: https://npmjs.org/package/argio
[travis-image]: https://img.shields.io/travis/devfans/argio/master.svg
[travis-url]: https://travis-ci.org/devfans/argio
[coveralls-image]: https://img.shields.io/coveralls/devfans/argio/master.svg
[coveralls-url]: https://coveralls.io/r/devfans/argio?branch=master
[downloads-image]: https://img.shields.io/npm/dm/argio.svg
[downloads-url]: https://npmjs.org/package/argio