initial
This commit is contained in:
8
node_modules/argv-tools/.travis.yml
generated
vendored
Normal file
8
node_modules/argv-tools/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 9
|
||||
- 8
|
||||
- 7
|
||||
- 6
|
||||
- 5
|
||||
- 4
|
21
node_modules/argv-tools/LICENSE
generated
vendored
Normal file
21
node_modules/argv-tools/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 Lloyd Brookes <75pound@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
11
node_modules/argv-tools/README.hbs
generated
vendored
Normal file
11
node_modules/argv-tools/README.hbs
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
[](https://www.npmjs.org/package/argv-tools)
|
||||
[](https://www.npmjs.org/package/argv-tools)
|
||||
[](https://travis-ci.org/75lb/argv-tools)
|
||||
[](https://david-dm.org/75lb/argv-tools)
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
{{>main}}
|
||||
|
||||
* * *
|
||||
|
||||
© 2018 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/75lb/jsdoc-to-markdown).
|
144
node_modules/argv-tools/README.md
generated
vendored
Normal file
144
node_modules/argv-tools/README.md
generated
vendored
Normal file
@ -0,0 +1,144 @@
|
||||
[](https://www.npmjs.org/package/argv-tools)
|
||||
[](https://www.npmjs.org/package/argv-tools)
|
||||
[](https://travis-ci.org/75lb/argv-tools)
|
||||
[](https://david-dm.org/75lb/argv-tools)
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
<a name="module_argv-tools"></a>
|
||||
|
||||
## argv-tools
|
||||
Some useful tools for working with `process.argv`.
|
||||
|
||||
**Example**
|
||||
```js
|
||||
const argvTools = require('argv-tools')
|
||||
```
|
||||
|
||||
* [argv-tools](#module_argv-tools)
|
||||
* [.ArgvArray](#module_argv-tools.ArgvArray)
|
||||
* [.load(argv)](#module_argv-tools.ArgvArray+load)
|
||||
* [.clear()](#module_argv-tools.ArgvArray+clear)
|
||||
* [.expandOptionEqualsNotation()](#module_argv-tools.ArgvArray+expandOptionEqualsNotation)
|
||||
* [.expandGetoptNotation()](#module_argv-tools.ArgvArray+expandGetoptNotation)
|
||||
* [.hasCombinedShortOptions()](#module_argv-tools.ArgvArray+hasCombinedShortOptions) ⇒ <code>boolean</code>
|
||||
* [.re](#module_argv-tools.re)
|
||||
* [.expandCombinedShortArg(arg)](#module_argv-tools.expandCombinedShortArg) ⇒ <code>Array.<string></code>
|
||||
* [.isOptionEqualsNotation(arg)](#module_argv-tools.isOptionEqualsNotation) ⇒ <code>boolean</code>
|
||||
* [.isOption(arg)](#module_argv-tools.isOption) ⇒ <code>boolean</code>
|
||||
* [.isLongOption(arg)](#module_argv-tools.isLongOption) ⇒ <code>boolean</code>
|
||||
* [.getOptionName(arg)](#module_argv-tools.getOptionName) ⇒ <code>string</code>
|
||||
|
||||
<a name="module_argv-tools.ArgvArray"></a>
|
||||
|
||||
### argvTools.ArgvArray
|
||||
Array subclass encapsulating common operations on `process.argv`.
|
||||
|
||||
**Kind**: static class of [<code>argv-tools</code>](#module_argv-tools)
|
||||
|
||||
* [.ArgvArray](#module_argv-tools.ArgvArray)
|
||||
* [.load(argv)](#module_argv-tools.ArgvArray+load)
|
||||
* [.clear()](#module_argv-tools.ArgvArray+clear)
|
||||
* [.expandOptionEqualsNotation()](#module_argv-tools.ArgvArray+expandOptionEqualsNotation)
|
||||
* [.expandGetoptNotation()](#module_argv-tools.ArgvArray+expandGetoptNotation)
|
||||
* [.hasCombinedShortOptions()](#module_argv-tools.ArgvArray+hasCombinedShortOptions) ⇒ <code>boolean</code>
|
||||
|
||||
<a name="module_argv-tools.ArgvArray+load"></a>
|
||||
|
||||
#### argvArray.load(argv)
|
||||
Clears the array has loads the supplied input.
|
||||
|
||||
**Kind**: instance method of [<code>ArgvArray</code>](#module_argv-tools.ArgvArray)
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| argv | <code>Array.<string></code> | The argv list to load. Defaults to `process.argv`. |
|
||||
|
||||
<a name="module_argv-tools.ArgvArray+clear"></a>
|
||||
|
||||
#### argvArray.clear()
|
||||
Clear the array.
|
||||
|
||||
**Kind**: instance method of [<code>ArgvArray</code>](#module_argv-tools.ArgvArray)
|
||||
<a name="module_argv-tools.ArgvArray+expandOptionEqualsNotation"></a>
|
||||
|
||||
#### argvArray.expandOptionEqualsNotation()
|
||||
expand ``--option=value` style args.
|
||||
|
||||
**Kind**: instance method of [<code>ArgvArray</code>](#module_argv-tools.ArgvArray)
|
||||
<a name="module_argv-tools.ArgvArray+expandGetoptNotation"></a>
|
||||
|
||||
#### argvArray.expandGetoptNotation()
|
||||
expand getopt-style combinedShort options.
|
||||
|
||||
**Kind**: instance method of [<code>ArgvArray</code>](#module_argv-tools.ArgvArray)
|
||||
<a name="module_argv-tools.ArgvArray+hasCombinedShortOptions"></a>
|
||||
|
||||
#### argvArray.hasCombinedShortOptions() ⇒ <code>boolean</code>
|
||||
Returns true if the array contains combined short options (e.g. `-ab`).
|
||||
|
||||
**Kind**: instance method of [<code>ArgvArray</code>](#module_argv-tools.ArgvArray)
|
||||
<a name="module_argv-tools.re"></a>
|
||||
|
||||
### argvTools.re
|
||||
Regular expressions for matching option formats.
|
||||
|
||||
**Kind**: static constant of [<code>argv-tools</code>](#module_argv-tools)
|
||||
<a name="module_argv-tools.expandCombinedShortArg"></a>
|
||||
|
||||
### argvTools.expandCombinedShortArg(arg) ⇒ <code>Array.<string></code>
|
||||
Expand a combined short option.
|
||||
|
||||
**Kind**: static method of [<code>argv-tools</code>](#module_argv-tools)
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| arg | <code>string</code> | the string to expand, e.g. `-ab` |
|
||||
|
||||
<a name="module_argv-tools.isOptionEqualsNotation"></a>
|
||||
|
||||
### argvTools.isOptionEqualsNotation(arg) ⇒ <code>boolean</code>
|
||||
Returns true if the supplied arg matches `--option=value` notation.
|
||||
|
||||
**Kind**: static method of [<code>argv-tools</code>](#module_argv-tools)
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| arg | <code>string</code> | the arg to test, e.g. `--one=something` |
|
||||
|
||||
<a name="module_argv-tools.isOption"></a>
|
||||
|
||||
### argvTools.isOption(arg) ⇒ <code>boolean</code>
|
||||
Returns true if the supplied arg is in either long (`--one`) or short (`-o`) format.
|
||||
|
||||
**Kind**: static method of [<code>argv-tools</code>](#module_argv-tools)
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| arg | <code>string</code> | the arg to test, e.g. `--one` |
|
||||
|
||||
<a name="module_argv-tools.isLongOption"></a>
|
||||
|
||||
### argvTools.isLongOption(arg) ⇒ <code>boolean</code>
|
||||
Returns true if the supplied arg is in long (`--one`) format.
|
||||
|
||||
**Kind**: static method of [<code>argv-tools</code>](#module_argv-tools)
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| arg | <code>string</code> | the arg to test, e.g. `--one` |
|
||||
|
||||
<a name="module_argv-tools.getOptionName"></a>
|
||||
|
||||
### argvTools.getOptionName(arg) ⇒ <code>string</code>
|
||||
Returns the name from a long, short or `--options=value` arg.
|
||||
|
||||
**Kind**: static method of [<code>argv-tools</code>](#module_argv-tools)
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| arg | <code>string</code> | the arg to inspect, e.g. `--one` |
|
||||
|
||||
|
||||
* * *
|
||||
|
||||
© 2018 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/75lb/jsdoc-to-markdown).
|
163
node_modules/argv-tools/index.js
generated
vendored
Normal file
163
node_modules/argv-tools/index.js
generated
vendored
Normal file
@ -0,0 +1,163 @@
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Some useful tools for working with `process.argv`.
|
||||
*
|
||||
* @module argv-tools
|
||||
* @typicalName argvTools
|
||||
* @example
|
||||
* const argvTools = require('argv-tools')
|
||||
*/
|
||||
|
||||
/**
|
||||
* Regular expressions for matching option formats.
|
||||
* @static
|
||||
*/
|
||||
const re = {
|
||||
short: /^-([^\d-])$/,
|
||||
long: /^--(\S+)/,
|
||||
combinedShort: /^-[^\d-]{2,}$/,
|
||||
optEquals: /^(--\S+?)=(.*)/
|
||||
}
|
||||
|
||||
/**
|
||||
* Array subclass encapsulating common operations on `process.argv`.
|
||||
* @static
|
||||
*/
|
||||
class ArgvArray extends Array {
|
||||
/**
|
||||
* Clears the array has loads the supplied input.
|
||||
* @param {string[]} argv - The argv list to load. Defaults to `process.argv`.
|
||||
*/
|
||||
load (argv) {
|
||||
const arrayify = require('array-back')
|
||||
this.clear()
|
||||
if (argv && argv !== process.argv) {
|
||||
argv = arrayify(argv)
|
||||
} else {
|
||||
/* if no argv supplied, assume we are parsing process.argv */
|
||||
argv = process.argv.slice(0)
|
||||
argv.splice(0, 2)
|
||||
}
|
||||
argv.forEach(arg => this.push(String(arg)))
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the array.
|
||||
*/
|
||||
clear () {
|
||||
this.length = 0
|
||||
}
|
||||
|
||||
/**
|
||||
* expand ``--option=value` style args.
|
||||
*/
|
||||
expandOptionEqualsNotation () {
|
||||
if (this.some(arg => re.optEquals.test(arg))) {
|
||||
const expandedArgs = []
|
||||
this.forEach(arg => {
|
||||
const matches = arg.match(re.optEquals)
|
||||
if (matches) {
|
||||
expandedArgs.push(matches[1], matches[2])
|
||||
} else {
|
||||
expandedArgs.push(arg)
|
||||
}
|
||||
})
|
||||
this.clear()
|
||||
this.load(expandedArgs)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* expand getopt-style combinedShort options.
|
||||
*/
|
||||
expandGetoptNotation () {
|
||||
if (this.hasCombinedShortOptions()) {
|
||||
const findReplace = require('find-replace')
|
||||
findReplace(this, re.combinedShort, expandCombinedShortArg)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array contains combined short options (e.g. `-ab`).
|
||||
* @returns {boolean}
|
||||
*/
|
||||
hasCombinedShortOptions () {
|
||||
return this.some(arg => re.combinedShort.test(arg))
|
||||
}
|
||||
|
||||
static from (argv) {
|
||||
const result = new this()
|
||||
result.load(argv)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand a combined short option.
|
||||
* @param {string} - the string to expand, e.g. `-ab`
|
||||
* @returns {string[]}
|
||||
* @static
|
||||
*/
|
||||
function expandCombinedShortArg (arg) {
|
||||
/* remove initial hypen */
|
||||
arg = arg.slice(1)
|
||||
return arg.split('').map(letter => '-' + letter)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the supplied arg matches `--option=value` notation.
|
||||
* @param {string} - the arg to test, e.g. `--one=something`
|
||||
* @returns {boolean}
|
||||
* @static
|
||||
*/
|
||||
function isOptionEqualsNotation (arg) {
|
||||
return re.optEquals.test(arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the supplied arg is in either long (`--one`) or short (`-o`) format.
|
||||
* @param {string} - the arg to test, e.g. `--one`
|
||||
* @returns {boolean}
|
||||
* @static
|
||||
*/
|
||||
function isOption (arg) {
|
||||
return (re.short.test(arg) || re.long.test(arg)) && !re.optEquals.test(arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the supplied arg is in long (`--one`) format.
|
||||
* @param {string} - the arg to test, e.g. `--one`
|
||||
* @returns {boolean}
|
||||
* @static
|
||||
*/
|
||||
function isLongOption (arg) {
|
||||
return re.long.test(arg) && !isOptionEqualsNotation(arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name from a long, short or `--options=value` arg.
|
||||
* @param {string} - the arg to inspect, e.g. `--one`
|
||||
* @returns {string}
|
||||
* @static
|
||||
*/
|
||||
function getOptionName (arg) {
|
||||
if (re.short.test(arg)) {
|
||||
return arg.match(re.short)[1]
|
||||
} else if (isLongOption(arg)) {
|
||||
return arg.match(re.long)[1]
|
||||
} else if (isOptionEqualsNotation(arg)) {
|
||||
return arg.match(re.optEquals)[1].replace(/^--/, '')
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
exports.expandCombinedShortArg = expandCombinedShortArg
|
||||
exports.re = re
|
||||
exports.ArgvArray = ArgvArray
|
||||
exports.getOptionName = getOptionName
|
||||
exports.isOption = isOption
|
||||
exports.isLongOption = isLongOption
|
||||
exports.isOptionEqualsNotation = isOptionEqualsNotation
|
||||
exports.isValue = arg => !(isOption(arg) || re.combinedShort.test(arg) || re.optEquals.test(arg))
|
71
node_modules/argv-tools/package.json
generated
vendored
Normal file
71
node_modules/argv-tools/package.json
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
{
|
||||
"_from": "argv-tools@^0.1.1",
|
||||
"_id": "argv-tools@0.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-Cc0dBvx4dvrjjKpyDA6w8RlNAw8Su30NvZbWl/Tv9ZALEVlLVkWQiHMi84Q0xNfpVuSaiQbYkdmWK8g1PLGhKw==",
|
||||
"_location": "/argv-tools",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "argv-tools@^0.1.1",
|
||||
"name": "argv-tools",
|
||||
"escapedName": "argv-tools",
|
||||
"rawSpec": "^0.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/command-line-args"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/argv-tools/-/argv-tools-0.1.1.tgz",
|
||||
"_shasum": "588283f3393ada47141440b12981cd41bf6b7032",
|
||||
"_spec": "argv-tools@^0.1.1",
|
||||
"_where": "/home/wn/workspace-node/PiAlive/node_modules/command-line-args",
|
||||
"author": {
|
||||
"name": "Lloyd Brookes",
|
||||
"email": "75pound@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/75lb/argv-tools/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"array-back": "^2.0.0",
|
||||
"find-replace": "^2.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "[](https://www.npmjs.org/package/argv-tools) [](https://www.npmjs.org/package/argv-tools) [](https://travis-ci.org/75lb/argv-tools) [](https://david-dm.org/75lb/argv-tools) [](https://github.com/feross/standard)",
|
||||
"devDependencies": {
|
||||
"jsdoc-to-markdown": "^3.0.3",
|
||||
"test-runner": "^0.5.0-1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/75lb/argv-tools#readme",
|
||||
"keywords": [
|
||||
"argv",
|
||||
"parse",
|
||||
"argument",
|
||||
"args",
|
||||
"option",
|
||||
"options",
|
||||
"parser",
|
||||
"parsing",
|
||||
"cli",
|
||||
"command",
|
||||
"line"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "argv-tools",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/75lb/argv-tools.git"
|
||||
},
|
||||
"scripts": {
|
||||
"docs": "jsdoc2md --template README.hbs index.js > README.md",
|
||||
"test": "test-runner test.js"
|
||||
},
|
||||
"version": "0.1.1"
|
||||
}
|
78
node_modules/argv-tools/test.js
generated
vendored
Normal file
78
node_modules/argv-tools/test.js
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
'use strict'
|
||||
const TestRunner = require('test-runner')
|
||||
const a = require('assert')
|
||||
const ArgvArray = require('./').ArgvArray
|
||||
const argvTools = require('./')
|
||||
|
||||
const runner = new TestRunner()
|
||||
|
||||
runner.test('argvArray.expandOptionEqualsNotation()', function () {
|
||||
const argv = new ArgvArray()
|
||||
argv.load([ '--one=1', '--two', '2', '--three=3', '4' ])
|
||||
argv.expandOptionEqualsNotation()
|
||||
a.deepEqual(argv, [
|
||||
'--one', '1', '--two', '2', '--three', '3', '4'
|
||||
])
|
||||
})
|
||||
|
||||
runner.test('argvArray.expandOptionEqualsNotation() 2', function () {
|
||||
const argv = new ArgvArray()
|
||||
argv.load([ '--one=tree' ])
|
||||
argv.expandOptionEqualsNotation()
|
||||
a.deepEqual(argv, [ '--one', 'tree' ])
|
||||
})
|
||||
|
||||
runner.test('argvArray.expandGetoptNotation()', function () {
|
||||
const argv = new ArgvArray()
|
||||
argv.load([ '-abc' ])
|
||||
argv.expandGetoptNotation()
|
||||
a.deepEqual(argv.slice(), [
|
||||
'-a', '-b', '-c'
|
||||
])
|
||||
})
|
||||
|
||||
runner.test('argvArray.expandGetoptNotation() with values', function () {
|
||||
const argv = new ArgvArray()
|
||||
argv.load([ '-abc', '1', '-a', '2', '-bc' ])
|
||||
argv.expandGetoptNotation()
|
||||
a.deepEqual(argv, [
|
||||
'-a', '-b', '-c', '1', '-a', '2', '-b', '-c'
|
||||
])
|
||||
})
|
||||
|
||||
runner.test('argvArray.hasCombinedShortOptions()', function () {
|
||||
const argv = new ArgvArray()
|
||||
argv.load([ '-abc', '1', '-a', '2' ])
|
||||
a.strictEqual(argv.hasCombinedShortOptions(), true)
|
||||
argv.load([ '1', '-a', '2' ])
|
||||
a.strictEqual(argv.hasCombinedShortOptions(), false)
|
||||
argv.load([ '1', '-ab', '2' ])
|
||||
a.strictEqual(argv.hasCombinedShortOptions(), true)
|
||||
})
|
||||
|
||||
runner.test('argvTools.isOption()', function () {
|
||||
a.strictEqual(argvTools.isOption('--yeah'), true)
|
||||
a.strictEqual(argvTools.isOption('--one-two'), true)
|
||||
a.strictEqual(argvTools.isOption('в--yeah'), false)
|
||||
a.strictEqual(argvTools.isOption('-y'), true)
|
||||
a.strictEqual(argvTools.isOption('--option=value'), false)
|
||||
a.strictEqual(argvTools.isOption('-asd'), false)
|
||||
})
|
||||
|
||||
runner.test('argvTools.isLongOption()', function () {
|
||||
a.strictEqual(argvTools.isLongOption('--yeah'), true)
|
||||
a.strictEqual(argvTools.isLongOption('--one-two'), true)
|
||||
a.strictEqual(argvTools.isLongOption('в--yeah'), false)
|
||||
a.strictEqual(argvTools.isLongOption('-y'), false)
|
||||
a.strictEqual(argvTools.isLongOption('--option=value'), false)
|
||||
a.strictEqual(argvTools.isLongOption('-asd'), false)
|
||||
})
|
||||
|
||||
runner.test('argvTools.getOptionName()', function () {
|
||||
a.strictEqual(argvTools.getOptionName('--yeah'), 'yeah')
|
||||
a.strictEqual(argvTools.getOptionName('--one-two'), 'one-two')
|
||||
a.strictEqual(argvTools.getOptionName('в--yeah'), null)
|
||||
a.strictEqual(argvTools.getOptionName('-y'), 'y')
|
||||
a.strictEqual(argvTools.getOptionName('--option=value'), 'option')
|
||||
a.strictEqual(argvTools.getOptionName('-asd'), null)
|
||||
})
|
Reference in New Issue
Block a user