Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yehorbk/cli-argv-parser
A library that allows to parse command line arguments into hash-table or object by scheme
https://github.com/yehorbk/cli-argv-parser
argument-parser argument-parsing arguments cli command-line javascript library parser parsing-library
Last synced: about 2 months ago
JSON representation
A library that allows to parse command line arguments into hash-table or object by scheme
- Host: GitHub
- URL: https://github.com/yehorbk/cli-argv-parser
- Owner: yehorbk
- License: mit
- Created: 2020-02-06T17:31:37.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-02-13T00:40:49.000Z (almost 3 years ago)
- Last Synced: 2024-10-08T11:44:42.004Z (3 months ago)
- Topics: argument-parser, argument-parsing, arguments, cli, command-line, javascript, library, parser, parsing-library
- Language: JavaScript
- Homepage:
- Size: 183 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Command Line Argumets Parser
A library that allows to parse command line arguments into hash-table or object by scheme.# Installation
Install library to your project:
```
$ npm install cli-argv-parser
```# How to use
You able to put only arguments array to parser and it will be return a hash-table (key-value).
But if you want to parse arguments into object - use template scheme with keys and required types.## Scheme:
```javascript
const scheme = {
file: String,
force: Boolean,
count: Number,
};
```
The template is `key`: `type`. Parser will try to convert argument into required type. By default single values will be always parsed into `Boolean` value.## Example of result:
- Without scheme: `{ '--file': 'app.js', force: true, '--count': '20' }`
- With scheme: `{ file: 'app.js', force: true, count: 20 }`# Author
**Yehor Bublyk**: [GitHub](https://github.com/yehorbk) • [Twitter](https://twitter.com/yehorbk)