mirror of
https://github.com/flynx/argv.js.git
synced 2025-10-29 18:50:09 +00:00
added architecture to docs...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
03e0456ff2
commit
4acd5a750f
41
README.md
41
README.md
@ -54,6 +54,7 @@ This code is an evolution of that parser.
|
|||||||
- [Features](#features)
|
- [Features](#features)
|
||||||
- [Planned Features](#planned-features)
|
- [Planned Features](#planned-features)
|
||||||
- [Contents](#contents)
|
- [Contents](#contents)
|
||||||
|
- [Architecture](#architecture)
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
- [Basics](#basics)
|
- [Basics](#basics)
|
||||||
- [Options in more detail](#options-in-more-detail)
|
- [Options in more detail](#options-in-more-detail)
|
||||||
@ -70,6 +71,46 @@ This code is an evolution of that parser.
|
|||||||
- [License](#license)
|
- [License](#license)
|
||||||
|
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
```
|
||||||
|
Parser(..) -> <parser> -> <parsed>
|
||||||
|
```
|
||||||
|
|
||||||
|
This module provides the following workflow:
|
||||||
|
|
||||||
|
- define/declare a parser (parse grammar)
|
||||||
|
```
|
||||||
|
Parser(<spec>)
|
||||||
|
-> <parser>
|
||||||
|
```
|
||||||
|
|
||||||
|
- define post-parse callbacks (optional)
|
||||||
|
```
|
||||||
|
<parser>
|
||||||
|
.then(<callback>)
|
||||||
|
.stop(<callback>)
|
||||||
|
.error(<callback>)
|
||||||
|
```
|
||||||
|
|
||||||
|
- parse
|
||||||
|
```
|
||||||
|
<parser>(process.argv)
|
||||||
|
-> <parsed>
|
||||||
|
```
|
||||||
|
- option handlers defined in `<spec>` are called while parsing,
|
||||||
|
- the appropriate `<callback>`s are called after the `<parser>` is done,
|
||||||
|
- everything is run in the context of the `<parsed>` object so any
|
||||||
|
data set on it is accessible after parding is done for further
|
||||||
|
reference.
|
||||||
|
|
||||||
|
Note that the `<parser>` is fully reusable and on each call will produce
|
||||||
|
a new `<parsed>` object.
|
||||||
|
|
||||||
|
The `<parsed>` object has the `<parser>` as its `.__proto__`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user