mirror of
https://github.com/flynx/argv.js.git
synced 2025-10-28 10:20:09 +00:00
more tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6731b64088
commit
fcb541f75d
30
ADVANCED.md
30
ADVANCED.md
@ -35,7 +35,9 @@ For basics see [README.md](./README.md)
|
||||
- [Automatically defined values](#automatically-defined-values)
|
||||
- [`<parser>.doc`](#parserdoc)
|
||||
- [`<parser>.usage`](#parserusage)
|
||||
- [`<parser>.packageJson`](#parserpackagejson)
|
||||
- [`<parser>.version`](#parserversion)
|
||||
- [`<parser>.author`](#parserauthor)
|
||||
- [`<parser>.license`](#parserlicense)
|
||||
- [`<parser>.examples`](#parserexamples)
|
||||
- [`<parser>.footer`](#parserfooter)
|
||||
@ -460,21 +462,47 @@ Basic usage hint.
|
||||
Default value: `"$SCRIPTNAME [OPTIONS]"`
|
||||
|
||||
|
||||
##### `<parser>.packageJson`
|
||||
|
||||
The path to the metadata JSON file.
|
||||
|
||||
<spec>.packageJson = <string> | <function> | undefined
|
||||
|
||||
If not set `package.json` will be searched for in the same directory as the
|
||||
main script.
|
||||
|
||||
Default value: `undefined`.
|
||||
|
||||
##### `<parser>.version`
|
||||
|
||||
Version number.
|
||||
|
||||
<spec>.usage = <string> | <function> | undefined
|
||||
|
||||
If this is not defined `-version` will print `"0.0.0"`.
|
||||
If this is not defined it will be read from the project metadata, if none is
|
||||
found `"0.0.0"` will be printed by `-version`.
|
||||
|
||||
Default value: `undefined`
|
||||
|
||||
|
||||
##### `<parser>.author`
|
||||
|
||||
Author name/contacts.
|
||||
|
||||
<spec>.author = <string> | <function> | undefined
|
||||
|
||||
If not set project metadata is used, if found.
|
||||
|
||||
Default value: `undefined`
|
||||
|
||||
##### `<parser>.license`
|
||||
|
||||
Short license information.
|
||||
|
||||
<spec>.usage = <string> | <function> | undefined
|
||||
|
||||
If not set project metadata is used, if found.
|
||||
|
||||
Default value: `undefined`
|
||||
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@ This code is an evolution of that parser.
|
||||
- Option/command value collection
|
||||
- Multiple option prefix support
|
||||
- Reasonable defaults:
|
||||
- Metadata defaults to `package.json`
|
||||
- `-help` – generate and print help
|
||||
- `-version` – print version
|
||||
- `-quiet` – suppress printing
|
||||
@ -198,6 +199,11 @@ Metadata:
|
||||
license: 'BSD-3-Clause',
|
||||
```
|
||||
|
||||
If not set, `.version`, `.author`, `.license` are acquired from `package.json`
|
||||
located at the same path as the main script.
|
||||
To explicitly set the path of the JSON file from which metadata is read set
|
||||
`.packageJson`.
|
||||
|
||||
These basic bits of metadata can be referenced in other `-help` sections,
|
||||
for example:
|
||||
```javascript
|
||||
|
||||
4
argv.js
4
argv.js
@ -137,7 +137,9 @@ function(attr, func){
|
||||
return function(p){
|
||||
try {
|
||||
var res = require(p
|
||||
|| this.packageJson
|
||||
|| (typeof(this.packageJson) == 'function' ?
|
||||
this.packageJson()
|
||||
: this.packageJson)
|
||||
|| path.dirname(
|
||||
(require.main || {}).filename || '.')
|
||||
+'/package.json')[attr]
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ig-argv",
|
||||
"version": "2.10.2",
|
||||
"version": "2.10.3",
|
||||
"description": "simple argv parser",
|
||||
"main": "argv.js",
|
||||
"scripts": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user