Merge branch 'main' into dependabot/npm_and_yarn/query-string-7.0.1
This commit is contained in:
Коммит
5643f45615
|
@ -289,7 +289,7 @@ exports.formatWorkflowCause = formatWorkflowCause;
|
|||
async function getWorkflow() {
|
||||
const relativePath = await getWorkflowPath();
|
||||
const absolutePath = path.join(util_1.getRequiredEnvParam("GITHUB_WORKSPACE"), relativePath);
|
||||
return yaml.safeLoad(fs.readFileSync(absolutePath, "utf-8"));
|
||||
return yaml.load(fs.readFileSync(absolutePath, "utf-8"));
|
||||
}
|
||||
exports.getWorkflow = getWorkflow;
|
||||
/**
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -139,7 +139,7 @@ ava_1.default("getWorkflowErrors() when on.pull_requests is a string and correct
|
|||
t.deepEqual(...errorCodes(errors, []));
|
||||
});
|
||||
ava_1.default("getWorkflowErrors() when on.push is correct with empty objects", (t) => {
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
@ -228,7 +228,7 @@ ava_1.default("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
|||
}), []));
|
||||
});
|
||||
ava_1.default("getWorkflowErrors() when on.pull_request for every branch but push specifies branches", (t) => {
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on:
|
||||
push:
|
||||
|
@ -311,7 +311,7 @@ ava_1.default("patternIsSuperset()", (t) => {
|
|||
t.false(actionsutil.patternIsSuperset("/robin/moose/release/goose", "/robin/*/release/*"));
|
||||
});
|
||||
ava_1.default("getWorkflowErrors() when branches contain dots", (t) => {
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||
on:
|
||||
push:
|
||||
branches: [4.1, master]
|
||||
|
@ -322,7 +322,7 @@ ava_1.default("getWorkflowErrors() when branches contain dots", (t) => {
|
|||
t.deepEqual(...errorCodes(errors, []));
|
||||
});
|
||||
ava_1.default("getWorkflowErrors() when on.push has a trailing comma", (t) => {
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on:
|
||||
push:
|
||||
|
@ -335,7 +335,7 @@ on:
|
|||
});
|
||||
ava_1.default("getWorkflowErrors() should only report the current job's CheckoutWrongHead", (t) => {
|
||||
process.env.GITHUB_JOB = "test";
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on:
|
||||
push:
|
||||
|
@ -359,7 +359,7 @@ jobs:
|
|||
});
|
||||
ava_1.default("getWorkflowErrors() should not report a different job's CheckoutWrongHead", (t) => {
|
||||
process.env.GITHUB_JOB = "test3";
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on:
|
||||
push:
|
||||
|
@ -382,34 +382,34 @@ jobs:
|
|||
t.deepEqual(...errorCodes(errors, []));
|
||||
});
|
||||
ava_1.default("getWorkflowErrors() when on is missing", (t) => {
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
`));
|
||||
t.deepEqual(...errorCodes(errors, []));
|
||||
});
|
||||
ava_1.default("getWorkflowErrors() with a different on setup", (t) => {
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on: "workflow_dispatch"
|
||||
`)), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on: [workflow_dispatch]
|
||||
`)), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
`)), []));
|
||||
});
|
||||
ava_1.default("getWorkflowErrors() should not report an error if PRs are totally unconfigured", (t) => {
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
`)), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on: ["push"]
|
||||
`)), []));
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -277,7 +277,7 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||
function readContents(name) {
|
||||
const x = fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8");
|
||||
console.log(x);
|
||||
return yaml.safeLoad(fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8"));
|
||||
return yaml.load(fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -723,7 +723,7 @@ function getLocalConfig(configFile, workspacePath) {
|
|||
if (!fs.existsSync(configFile)) {
|
||||
throw new Error(getConfigFileDoesNotExistErrorMessage(configFile));
|
||||
}
|
||||
return yaml.safeLoad(fs.readFileSync(configFile, "utf8"));
|
||||
return yaml.load(fs.readFileSync(configFile, "utf8"));
|
||||
}
|
||||
async function getRemoteConfig(configFile, apiDetails) {
|
||||
// retrieve the various parts of the config location, and ensure they're present
|
||||
|
@ -751,7 +751,7 @@ async function getRemoteConfig(configFile, apiDetails) {
|
|||
else {
|
||||
throw new Error(getConfigFileFormatInvalidMessage(configFile));
|
||||
}
|
||||
return yaml.safeLoad(Buffer.from(fileContents, "base64").toString("binary"));
|
||||
return yaml.load(Buffer.from(fileContents, "base64").toString("binary"));
|
||||
}
|
||||
/**
|
||||
* Get the file path where the parsed config will be stored.
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
0
node_modules/js-yaml/node_modules/.bin/esparse → node_modules/.bin/esparse
сгенерированный
поставляемый
0
node_modules/js-yaml/node_modules/.bin/esparse → node_modules/.bin/esparse
сгенерированный
поставляемый
0
node_modules/js-yaml/node_modules/.bin/esvalidate → node_modules/.bin/esvalidate
сгенерированный
поставляемый
0
node_modules/js-yaml/node_modules/.bin/esvalidate → node_modules/.bin/esvalidate
сгенерированный
поставляемый
|
@ -178,6 +178,15 @@
|
|||
"node": "^10.12.0 || >=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc/node_modules/argparse": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc/node_modules/ignore": {
|
||||
"version": "4.0.6",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
|
||||
|
@ -187,6 +196,19 @@
|
|||
"node": ">= 4"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc/node_modules/js-yaml": {
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
|
||||
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc/node_modules/strip-json-comments": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
|
||||
|
@ -809,11 +831,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/argparse": {
|
||||
"version": "1.0.10",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
|
||||
},
|
||||
"node_modules/array-find-index": {
|
||||
"version": "1.0.2",
|
||||
|
@ -2320,6 +2340,15 @@
|
|||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/argparse": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/chalk": {
|
||||
"version": "4.1.0",
|
||||
"dev": true,
|
||||
|
@ -2403,6 +2432,19 @@
|
|||
"node": ">= 4"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/js-yaml": {
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
|
||||
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/path-key": {
|
||||
"version": "3.1.1",
|
||||
"dev": true,
|
||||
|
@ -2489,6 +2531,19 @@
|
|||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"esparse": "bin/esparse.js",
|
||||
"esvalidate": "bin/esvalidate.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/esquery": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz",
|
||||
|
@ -3358,27 +3413,16 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/js-yaml": {
|
||||
"version": "3.13.1",
|
||||
"license": "MIT",
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
||||
"dependencies": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
"argparse": "^2.0.1"
|
||||
},
|
||||
"bin": {
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/js-yaml/node_modules/esprima": {
|
||||
"version": "4.0.1",
|
||||
"license": "BSD-2-Clause",
|
||||
"bin": {
|
||||
"esparse": "bin/esparse.js",
|
||||
"esvalidate": "bin/esvalidate.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/json-buffer": {
|
||||
"version": "3.0.0",
|
||||
"dev": true,
|
||||
|
@ -4986,7 +5030,9 @@
|
|||
},
|
||||
"node_modules/sprintf-js": {
|
||||
"version": "1.0.3",
|
||||
"license": "BSD-3-Clause"
|
||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/strict-uri-encode": {
|
||||
"version": "2.0.0",
|
||||
|
@ -5092,6 +5138,15 @@
|
|||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/supertap/node_modules/argparse": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/supertap/node_modules/arrify": {
|
||||
"version": "1.0.1",
|
||||
"dev": true,
|
||||
|
@ -5108,6 +5163,19 @@
|
|||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/supertap/node_modules/js-yaml": {
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
|
||||
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/supertap/node_modules/strip-ansi": {
|
||||
"version": "4.0.0",
|
||||
"dev": true,
|
||||
|
|
1
node_modules/@eslint/eslintrc/node_modules/.bin/js-yaml
сгенерированный
поставляемый
Symbolic link
1
node_modules/@eslint/eslintrc/node_modules/.bin/js-yaml
сгенерированный
поставляемый
Symbolic link
|
@ -0,0 +1 @@
|
|||
../js-yaml/bin/js-yaml.js
|
185
node_modules/@eslint/eslintrc/node_modules/argparse/CHANGELOG.md
сгенерированный
поставляемый
Normal file
185
node_modules/@eslint/eslintrc/node_modules/argparse/CHANGELOG.md
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,185 @@
|
|||
1.0.10 / 2018-02-15
|
||||
------------------
|
||||
|
||||
- Use .concat instead of + for arrays, #122.
|
||||
|
||||
|
||||
1.0.9 / 2016-09-29
|
||||
------------------
|
||||
|
||||
- Rerelease after 1.0.8 - deps cleanup.
|
||||
|
||||
|
||||
1.0.8 / 2016-09-29
|
||||
------------------
|
||||
|
||||
- Maintenance (deps bump, fix node 6.5+ tests, coverage report).
|
||||
|
||||
|
||||
1.0.7 / 2016-03-17
|
||||
------------------
|
||||
|
||||
- Teach `addArgument` to accept string arg names. #97, @tomxtobin.
|
||||
|
||||
|
||||
1.0.6 / 2016-02-06
|
||||
------------------
|
||||
|
||||
- Maintenance: moved to eslint & updated CS.
|
||||
|
||||
|
||||
1.0.5 / 2016-02-05
|
||||
------------------
|
||||
|
||||
- Removed lodash dependency to significantly reduce install size.
|
||||
Thanks to @mourner.
|
||||
|
||||
|
||||
1.0.4 / 2016-01-17
|
||||
------------------
|
||||
|
||||
- Maintenance: lodash update to 4.0.0.
|
||||
|
||||
|
||||
1.0.3 / 2015-10-27
|
||||
------------------
|
||||
|
||||
- Fix parse `=` in args: `--examplepath="C:\myfolder\env=x64"`. #84, @CatWithApple.
|
||||
|
||||
|
||||
1.0.2 / 2015-03-22
|
||||
------------------
|
||||
|
||||
- Relaxed lodash version dependency.
|
||||
|
||||
|
||||
1.0.1 / 2015-02-20
|
||||
------------------
|
||||
|
||||
- Changed dependencies to be compatible with ancient nodejs.
|
||||
|
||||
|
||||
1.0.0 / 2015-02-19
|
||||
------------------
|
||||
|
||||
- Maintenance release.
|
||||
- Replaced `underscore` with `lodash`.
|
||||
- Bumped version to 1.0.0 to better reflect semver meaning.
|
||||
- HISTORY.md -> CHANGELOG.md
|
||||
|
||||
|
||||
0.1.16 / 2013-12-01
|
||||
-------------------
|
||||
|
||||
- Maintenance release. Updated dependencies and docs.
|
||||
|
||||
|
||||
0.1.15 / 2013-05-13
|
||||
-------------------
|
||||
|
||||
- Fixed #55, @trebor89
|
||||
|
||||
|
||||
0.1.14 / 2013-05-12
|
||||
-------------------
|
||||
|
||||
- Fixed #62, @maxtaco
|
||||
|
||||
|
||||
0.1.13 / 2013-04-08
|
||||
-------------------
|
||||
|
||||
- Added `.npmignore` to reduce package size
|
||||
|
||||
|
||||
0.1.12 / 2013-02-10
|
||||
-------------------
|
||||
|
||||
- Fixed conflictHandler (#46), @hpaulj
|
||||
|
||||
|
||||
0.1.11 / 2013-02-07
|
||||
-------------------
|
||||
|
||||
- Multiple bugfixes, @hpaulj
|
||||
- Added 70+ tests (ported from python), @hpaulj
|
||||
- Added conflictHandler, @applepicke
|
||||
- Added fromfilePrefixChar, @hpaulj
|
||||
|
||||
|
||||
0.1.10 / 2012-12-30
|
||||
-------------------
|
||||
|
||||
- Added [mutual exclusion](http://docs.python.org/dev/library/argparse.html#mutual-exclusion)
|
||||
support, thanks to @hpaulj
|
||||
- Fixed options check for `storeConst` & `appendConst` actions, thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.9 / 2012-12-27
|
||||
------------------
|
||||
|
||||
- Fixed option dest interferens with other options (issue #23), thanks to @hpaulj
|
||||
- Fixed default value behavior with `*` positionals, thanks to @hpaulj
|
||||
- Improve `getDefault()` behavior, thanks to @hpaulj
|
||||
- Imrove negative argument parsing, thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.8 / 2012-12-01
|
||||
------------------
|
||||
|
||||
- Fixed parser parents (issue #19), thanks to @hpaulj
|
||||
- Fixed negative argument parse (issue #20), thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.7 / 2012-10-14
|
||||
------------------
|
||||
|
||||
- Fixed 'choices' argument parse (issue #16)
|
||||
- Fixed stderr output (issue #15)
|
||||
|
||||
|
||||
0.1.6 / 2012-09-09
|
||||
------------------
|
||||
|
||||
- Fixed check for conflict of options (thanks to @tomxtobin)
|
||||
|
||||
|
||||
0.1.5 / 2012-09-03
|
||||
------------------
|
||||
|
||||
- Fix parser #setDefaults method (thanks to @tomxtobin)
|
||||
|
||||
|
||||
0.1.4 / 2012-07-30
|
||||
------------------
|
||||
|
||||
- Fixed pseudo-argument support (thanks to @CGamesPlay)
|
||||
- Fixed addHelp default (should be true), if not set (thanks to @benblank)
|
||||
|
||||
|
||||
0.1.3 / 2012-06-27
|
||||
------------------
|
||||
|
||||
- Fixed formatter api name: Formatter -> HelpFormatter
|
||||
|
||||
|
||||
0.1.2 / 2012-05-29
|
||||
------------------
|
||||
|
||||
- Added basic tests
|
||||
- Removed excess whitespace in help
|
||||
- Fixed error reporting, when parcer with subcommands
|
||||
called with empty arguments
|
||||
|
||||
|
||||
0.1.1 / 2012-05-23
|
||||
------------------
|
||||
|
||||
- Fixed line wrapping in help formatter
|
||||
- Added better error reporting on invalid arguments
|
||||
|
||||
|
||||
0.1.0 / 2012-05-16
|
||||
------------------
|
||||
|
||||
- First release.
|
21
node_modules/@eslint/eslintrc/node_modules/argparse/LICENSE
сгенерированный
поставляемый
Normal file
21
node_modules/@eslint/eslintrc/node_modules/argparse/LICENSE
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,21 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (C) 2012 by Vitaly Puzrin
|
||||
|
||||
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.
|
257
node_modules/@eslint/eslintrc/node_modules/argparse/README.md
сгенерированный
поставляемый
Normal file
257
node_modules/@eslint/eslintrc/node_modules/argparse/README.md
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,257 @@
|
|||
argparse
|
||||
========
|
||||
|
||||
[![Build Status](https://secure.travis-ci.org/nodeca/argparse.svg?branch=master)](http://travis-ci.org/nodeca/argparse)
|
||||
[![NPM version](https://img.shields.io/npm/v/argparse.svg)](https://www.npmjs.org/package/argparse)
|
||||
|
||||
CLI arguments parser for node.js. Javascript port of python's
|
||||
[argparse](http://docs.python.org/dev/library/argparse.html) module
|
||||
(original version 3.2). That's a full port, except some very rare options,
|
||||
recorded in issue tracker.
|
||||
|
||||
**NB. Difference with original.**
|
||||
|
||||
- Method names changed to camelCase. See [generated docs](http://nodeca.github.com/argparse/).
|
||||
- Use `defaultValue` instead of `default`.
|
||||
- Use `argparse.Const.REMAINDER` instead of `argparse.REMAINDER`, and
|
||||
similarly for constant values `OPTIONAL`, `ZERO_OR_MORE`, and `ONE_OR_MORE`
|
||||
(aliases for `nargs` values `'?'`, `'*'`, `'+'`, respectively), and
|
||||
`SUPPRESS`.
|
||||
|
||||
|
||||
Example
|
||||
=======
|
||||
|
||||
test.js file:
|
||||
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({
|
||||
version: '0.0.1',
|
||||
addHelp:true,
|
||||
description: 'Argparse example'
|
||||
});
|
||||
parser.addArgument(
|
||||
[ '-f', '--foo' ],
|
||||
{
|
||||
help: 'foo bar'
|
||||
}
|
||||
);
|
||||
parser.addArgument(
|
||||
[ '-b', '--bar' ],
|
||||
{
|
||||
help: 'bar foo'
|
||||
}
|
||||
);
|
||||
parser.addArgument(
|
||||
'--baz',
|
||||
{
|
||||
help: 'baz bar'
|
||||
}
|
||||
);
|
||||
var args = parser.parseArgs();
|
||||
console.dir(args);
|
||||
```
|
||||
|
||||
Display help:
|
||||
|
||||
```
|
||||
$ ./test.js -h
|
||||
usage: example.js [-h] [-v] [-f FOO] [-b BAR] [--baz BAZ]
|
||||
|
||||
Argparse example
|
||||
|
||||
Optional arguments:
|
||||
-h, --help Show this help message and exit.
|
||||
-v, --version Show program's version number and exit.
|
||||
-f FOO, --foo FOO foo bar
|
||||
-b BAR, --bar BAR bar foo
|
||||
--baz BAZ baz bar
|
||||
```
|
||||
|
||||
Parse arguments:
|
||||
|
||||
```
|
||||
$ ./test.js -f=3 --bar=4 --baz 5
|
||||
{ foo: '3', bar: '4', baz: '5' }
|
||||
```
|
||||
|
||||
More [examples](https://github.com/nodeca/argparse/tree/master/examples).
|
||||
|
||||
|
||||
ArgumentParser objects
|
||||
======================
|
||||
|
||||
```
|
||||
new ArgumentParser({parameters hash});
|
||||
```
|
||||
|
||||
Creates a new ArgumentParser object.
|
||||
|
||||
**Supported params:**
|
||||
|
||||
- ```description``` - Text to display before the argument help.
|
||||
- ```epilog``` - Text to display after the argument help.
|
||||
- ```addHelp``` - Add a -h/–help option to the parser. (default: true)
|
||||
- ```argumentDefault``` - Set the global default value for arguments. (default: null)
|
||||
- ```parents``` - A list of ArgumentParser objects whose arguments should also be included.
|
||||
- ```prefixChars``` - The set of characters that prefix optional arguments. (default: ‘-‘)
|
||||
- ```formatterClass``` - A class for customizing the help output.
|
||||
- ```prog``` - The name of the program (default: `path.basename(process.argv[1])`)
|
||||
- ```usage``` - The string describing the program usage (default: generated)
|
||||
- ```conflictHandler``` - Usually unnecessary, defines strategy for resolving conflicting optionals.
|
||||
|
||||
**Not supported yet**
|
||||
|
||||
- ```fromfilePrefixChars``` - The set of characters that prefix files from which additional arguments should be read.
|
||||
|
||||
|
||||
Details in [original ArgumentParser guide](http://docs.python.org/dev/library/argparse.html#argumentparser-objects)
|
||||
|
||||
|
||||
addArgument() method
|
||||
====================
|
||||
|
||||
```
|
||||
ArgumentParser.addArgument(name or flag or [name] or [flags...], {options})
|
||||
```
|
||||
|
||||
Defines how a single command-line argument should be parsed.
|
||||
|
||||
- ```name or flag or [name] or [flags...]``` - Either a positional name
|
||||
(e.g., `'foo'`), a single option (e.g., `'-f'` or `'--foo'`), an array
|
||||
of a single positional name (e.g., `['foo']`), or an array of options
|
||||
(e.g., `['-f', '--foo']`).
|
||||
|
||||
Options:
|
||||
|
||||
- ```action``` - The basic type of action to be taken when this argument is encountered at the command line.
|
||||
- ```nargs```- The number of command-line arguments that should be consumed.
|
||||
- ```constant``` - A constant value required by some action and nargs selections.
|
||||
- ```defaultValue``` - The value produced if the argument is absent from the command line.
|
||||
- ```type``` - The type to which the command-line argument should be converted.
|
||||
- ```choices``` - A container of the allowable values for the argument.
|
||||
- ```required``` - Whether or not the command-line option may be omitted (optionals only).
|
||||
- ```help``` - A brief description of what the argument does.
|
||||
- ```metavar``` - A name for the argument in usage messages.
|
||||
- ```dest``` - The name of the attribute to be added to the object returned by parseArgs().
|
||||
|
||||
Details in [original add_argument guide](http://docs.python.org/dev/library/argparse.html#the-add-argument-method)
|
||||
|
||||
|
||||
Action (some details)
|
||||
================
|
||||
|
||||
ArgumentParser objects associate command-line arguments with actions.
|
||||
These actions can do just about anything with the command-line arguments associated
|
||||
with them, though most actions simply add an attribute to the object returned by
|
||||
parseArgs(). The action keyword argument specifies how the command-line arguments
|
||||
should be handled. The supported actions are:
|
||||
|
||||
- ```store``` - Just stores the argument’s value. This is the default action.
|
||||
- ```storeConst``` - Stores value, specified by the const keyword argument.
|
||||
(Note that the const keyword argument defaults to the rather unhelpful None.)
|
||||
The 'storeConst' action is most commonly used with optional arguments, that
|
||||
specify some sort of flag.
|
||||
- ```storeTrue``` and ```storeFalse``` - Stores values True and False
|
||||
respectively. These are special cases of 'storeConst'.
|
||||
- ```append``` - Stores a list, and appends each argument value to the list.
|
||||
This is useful to allow an option to be specified multiple times.
|
||||
- ```appendConst``` - Stores a list, and appends value, specified by the
|
||||
const keyword argument to the list. (Note, that the const keyword argument defaults
|
||||
is None.) The 'appendConst' action is typically used when multiple arguments need
|
||||
to store constants to the same list.
|
||||
- ```count``` - Counts the number of times a keyword argument occurs. For example,
|
||||
used for increasing verbosity levels.
|
||||
- ```help``` - Prints a complete help message for all the options in the current
|
||||
parser and then exits. By default a help action is automatically added to the parser.
|
||||
See ArgumentParser for details of how the output is created.
|
||||
- ```version``` - Prints version information and exit. Expects a `version=`
|
||||
keyword argument in the addArgument() call.
|
||||
|
||||
Details in [original action guide](http://docs.python.org/dev/library/argparse.html#action)
|
||||
|
||||
|
||||
Sub-commands
|
||||
============
|
||||
|
||||
ArgumentParser.addSubparsers()
|
||||
|
||||
Many programs split their functionality into a number of sub-commands, for
|
||||
example, the svn program can invoke sub-commands like `svn checkout`, `svn update`,
|
||||
and `svn commit`. Splitting up functionality this way can be a particularly good
|
||||
idea when a program performs several different functions which require different
|
||||
kinds of command-line arguments. `ArgumentParser` supports creation of such
|
||||
sub-commands with `addSubparsers()` method. The `addSubparsers()` method is
|
||||
normally called with no arguments and returns an special action object.
|
||||
This object has a single method `addParser()`, which takes a command name and
|
||||
any `ArgumentParser` constructor arguments, and returns an `ArgumentParser` object
|
||||
that can be modified as usual.
|
||||
|
||||
Example:
|
||||
|
||||
sub_commands.js
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({
|
||||
version: '0.0.1',
|
||||
addHelp:true,
|
||||
description: 'Argparse examples: sub-commands',
|
||||
});
|
||||
|
||||
var subparsers = parser.addSubparsers({
|
||||
title:'subcommands',
|
||||
dest:"subcommand_name"
|
||||
});
|
||||
|
||||
var bar = subparsers.addParser('c1', {addHelp:true});
|
||||
bar.addArgument(
|
||||
[ '-f', '--foo' ],
|
||||
{
|
||||
action: 'store',
|
||||
help: 'foo3 bar3'
|
||||
}
|
||||
);
|
||||
var bar = subparsers.addParser(
|
||||
'c2',
|
||||
{aliases:['co'], addHelp:true}
|
||||
);
|
||||
bar.addArgument(
|
||||
[ '-b', '--bar' ],
|
||||
{
|
||||
action: 'store',
|
||||
type: 'int',
|
||||
help: 'foo3 bar3'
|
||||
}
|
||||
);
|
||||
|
||||
var args = parser.parseArgs();
|
||||
console.dir(args);
|
||||
|
||||
```
|
||||
|
||||
Details in [original sub-commands guide](http://docs.python.org/dev/library/argparse.html#sub-commands)
|
||||
|
||||
|
||||
Contributors
|
||||
============
|
||||
|
||||
- [Eugene Shkuropat](https://github.com/shkuropat)
|
||||
- [Paul Jacobson](https://github.com/hpaulj)
|
||||
|
||||
[others](https://github.com/nodeca/argparse/graphs/contributors)
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
Copyright (c) 2012 [Vitaly Puzrin](https://github.com/puzrin).
|
||||
Released under the MIT license. See
|
||||
[LICENSE](https://github.com/nodeca/argparse/blob/master/LICENSE) for details.
|
||||
|
||||
|
0
node_modules/argparse/index.js → node_modules/@eslint/eslintrc/node_modules/argparse/index.js
сгенерированный
поставляемый
0
node_modules/argparse/index.js → node_modules/@eslint/eslintrc/node_modules/argparse/index.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/append.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/append.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/append.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/append.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/count.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/count.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/count.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/count.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/help.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/help.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/help.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/help.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/store.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/store.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/store.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/store.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/version.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/version.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/version.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/version.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action_container.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action_container.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action_container.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action_container.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argparse.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argparse.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argparse.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argparse.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argument/error.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argument/error.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argument/error.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argument/error.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argument/group.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argument/group.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argument/group.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argument/group.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argument_parser.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argument_parser.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argument_parser.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argument_parser.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/const.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/const.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/const.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/const.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/help/formatter.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/help/formatter.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/help/formatter.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/help/formatter.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/namespace.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/namespace.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/namespace.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/namespace.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/utils.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/utils.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/utils.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/utils.js
сгенерированный
поставляемый
34
node_modules/@eslint/eslintrc/node_modules/argparse/package.json
сгенерированный
поставляемый
Normal file
34
node_modules/@eslint/eslintrc/node_modules/argparse/package.json
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"name": "argparse",
|
||||
"description": "Very powerful CLI arguments parser. Native port of argparse - python's options parsing library",
|
||||
"version": "1.0.10",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"parser",
|
||||
"argparse",
|
||||
"option",
|
||||
"args"
|
||||
],
|
||||
"contributors": [
|
||||
"Eugene Shkuropat",
|
||||
"Paul Jacobson"
|
||||
],
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "nodeca/argparse",
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^2.13.1",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^3.1.0",
|
||||
"ndoc": "^5.0.1"
|
||||
}
|
||||
}
|
557
node_modules/@eslint/eslintrc/node_modules/js-yaml/CHANGELOG.md
сгенерированный
поставляемый
Normal file
557
node_modules/@eslint/eslintrc/node_modules/js-yaml/CHANGELOG.md
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,557 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
|
||||
## [3.14.1] - 2020-12-07
|
||||
### Security
|
||||
- Fix possible code execution in (already unsafe) `.load()` (in &anchor).
|
||||
|
||||
|
||||
## [3.14.0] - 2020-05-22
|
||||
### Changed
|
||||
- Support `safe/loadAll(input, options)` variant of call.
|
||||
- CI: drop outdated nodejs versions.
|
||||
- Dev deps bump.
|
||||
|
||||
### Fixed
|
||||
- Quote `=` in plain scalars #519.
|
||||
- Check the node type for `!<?>` tag in case user manually specifies it.
|
||||
- Verify that there are no null-bytes in input.
|
||||
- Fix wrong quote position when writing condensed flow, #526.
|
||||
|
||||
|
||||
## [3.13.1] - 2019-04-05
|
||||
### Security
|
||||
- Fix possible code execution in (already unsafe) `.load()`, #480.
|
||||
|
||||
|
||||
## [3.13.0] - 2019-03-20
|
||||
### Security
|
||||
- Security fix: `safeLoad()` can hang when arrays with nested refs
|
||||
used as key. Now throws exception for nested arrays. #475.
|
||||
|
||||
|
||||
## [3.12.2] - 2019-02-26
|
||||
### Fixed
|
||||
- Fix `noArrayIndent` option for root level, #468.
|
||||
|
||||
|
||||
## [3.12.1] - 2019-01-05
|
||||
### Added
|
||||
- Added `noArrayIndent` option, #432.
|
||||
|
||||
|
||||
## [3.12.0] - 2018-06-02
|
||||
### Changed
|
||||
- Support arrow functions without a block statement, #421.
|
||||
|
||||
|
||||
## [3.11.0] - 2018-03-05
|
||||
### Added
|
||||
- Add arrow functions suport for `!!js/function`.
|
||||
|
||||
### Fixed
|
||||
- Fix dump in bin/octal/hex formats for negative integers, #399.
|
||||
|
||||
|
||||
## [3.10.0] - 2017-09-10
|
||||
### Fixed
|
||||
- Fix `condenseFlow` output (quote keys for sure, instead of spaces), #371, #370.
|
||||
- Dump astrals as codepoints instead of surrogate pair, #368.
|
||||
|
||||
|
||||
## [3.9.1] - 2017-07-08
|
||||
### Fixed
|
||||
- Ensure stack is present for custom errors in node 7.+, #351.
|
||||
|
||||
|
||||
## [3.9.0] - 2017-07-08
|
||||
### Added
|
||||
- Add `condenseFlow` option (to create pretty URL query params), #346.
|
||||
|
||||
### Fixed
|
||||
- Support array return from safeLoadAll/loadAll, #350.
|
||||
|
||||
|
||||
## [3.8.4] - 2017-05-08
|
||||
### Fixed
|
||||
- Dumper: prevent space after dash for arrays that wrap, #343.
|
||||
|
||||
|
||||
## [3.8.3] - 2017-04-05
|
||||
### Fixed
|
||||
- Should not allow numbers to begin and end with underscore, #335.
|
||||
|
||||
|
||||
## [3.8.2] - 2017-03-02
|
||||
### Fixed
|
||||
- Fix `!!float 123` (integers) parse, #333.
|
||||
- Don't allow leading zeros in floats (except 0, 0.xxx).
|
||||
- Allow positive exponent without sign in floats.
|
||||
|
||||
|
||||
## [3.8.1] - 2017-02-07
|
||||
### Changed
|
||||
- Maintenance: update browserified build.
|
||||
|
||||
|
||||
## [3.8.0] - 2017-02-07
|
||||
### Fixed
|
||||
- Fix reported position for `duplicated mapping key` errors.
|
||||
Now points to block start instead of block end.
|
||||
(#243, thanks to @shockey).
|
||||
|
||||
|
||||
## [3.7.0] - 2016-11-12
|
||||
### Added
|
||||
- Support polymorphism for tags (#300, thanks to @monken).
|
||||
|
||||
### Fixed
|
||||
- Fix parsing of quotes followed by newlines (#304, thanks to @dplepage).
|
||||
|
||||
|
||||
## [3.6.1] - 2016-05-11
|
||||
### Fixed
|
||||
- Fix output cut on a pipe, #286.
|
||||
|
||||
|
||||
## [3.6.0] - 2016-04-16
|
||||
### Fixed
|
||||
- Dumper rewrite, fix multiple bugs with trailing `\n`.
|
||||
Big thanks to @aepsilon!
|
||||
- Loader: fix leading/trailing newlines in block scalars, @aepsilon.
|
||||
|
||||
|
||||
## [3.5.5] - 2016-03-17
|
||||
### Fixed
|
||||
- Date parse fix: don't allow dates with on digit in month and day, #268.
|
||||
|
||||
|
||||
## [3.5.4] - 2016-03-09
|
||||
### Added
|
||||
- `noCompatMode` for dumper, to disable quoting YAML 1.1 values.
|
||||
|
||||
|
||||
## [3.5.3] - 2016-02-11
|
||||
### Changed
|
||||
- Maintenance release.
|
||||
|
||||
|
||||
## [3.5.2] - 2016-01-11
|
||||
### Changed
|
||||
- Maintenance: missed comma in bower config.
|
||||
|
||||
|
||||
## [3.5.1] - 2016-01-11
|
||||
### Changed
|
||||
- Removed `inherit` dependency, #239.
|
||||
- Better browserify workaround for esprima load.
|
||||
- Demo rewrite.
|
||||
|
||||
|
||||
## [3.5.0] - 2016-01-10
|
||||
### Fixed
|
||||
- Dumper. Fold strings only, #217.
|
||||
- Dumper. `norefs` option, to clone linked objects, #229.
|
||||
- Loader. Throw a warning for duplicate keys, #166.
|
||||
- Improved browserify support (mark `esprima` & `Buffer` excluded).
|
||||
|
||||
|
||||
## [3.4.6] - 2015-11-26
|
||||
### Changed
|
||||
- Use standalone `inherit` to keep browserified files clear.
|
||||
|
||||
|
||||
## [3.4.5] - 2015-11-23
|
||||
### Added
|
||||
- Added `lineWidth` option to dumper.
|
||||
|
||||
|
||||
## [3.4.4] - 2015-11-21
|
||||
### Fixed
|
||||
- Fixed floats dump (missed dot for scientific format), #220.
|
||||
- Allow non-printable characters inside quoted scalars, #192.
|
||||
|
||||
|
||||
## [3.4.3] - 2015-10-10
|
||||
### Changed
|
||||
- Maintenance release - deps bump (esprima, argparse).
|
||||
|
||||
|
||||
## [3.4.2] - 2015-09-09
|
||||
### Fixed
|
||||
- Fixed serialization of duplicated entries in sequences, #205.
|
||||
Thanks to @vogelsgesang.
|
||||
|
||||
|
||||
## [3.4.1] - 2015-09-05
|
||||
### Fixed
|
||||
- Fixed stacktrace handling in generated errors, for browsers (FF/IE).
|
||||
|
||||
|
||||
## [3.4.0] - 2015-08-23
|
||||
### Changed
|
||||
- Don't throw on warnings anymore. Use `onWarning` option to catch.
|
||||
- Throw error on unknown tags (was warning before).
|
||||
- Reworked internals of error class.
|
||||
|
||||
### Fixed
|
||||
- Fixed multiline keys dump, #197. Thanks to @tcr.
|
||||
- Fixed heading line breaks in some scalars (regression).
|
||||
|
||||
|
||||
## [3.3.1] - 2015-05-13
|
||||
### Added
|
||||
- Added `.sortKeys` dumper option, thanks to @rjmunro.
|
||||
|
||||
### Fixed
|
||||
- Fixed astral characters support, #191.
|
||||
|
||||
|
||||
## [3.3.0] - 2015-04-26
|
||||
### Changed
|
||||
- Significantly improved long strings formatting in dumper, thanks to @isaacs.
|
||||
- Strip BOM if exists.
|
||||
|
||||
|
||||
## [3.2.7] - 2015-02-19
|
||||
### Changed
|
||||
- Maintenance release.
|
||||
- Updated dependencies.
|
||||
- HISTORY.md -> CHANGELOG.md
|
||||
|
||||
|
||||
## [3.2.6] - 2015-02-07
|
||||
### Fixed
|
||||
- Fixed encoding of UTF-16 surrogate pairs. (e.g. "\U0001F431" CAT FACE).
|
||||
- Fixed demo dates dump (#113, thanks to @Hypercubed).
|
||||
|
||||
|
||||
## [3.2.5] - 2014-12-28
|
||||
### Fixed
|
||||
- Fixed resolving of all built-in types on empty nodes.
|
||||
- Fixed invalid warning on empty lines within quoted scalars and flow collections.
|
||||
- Fixed bug: Tag on an empty node didn't resolve in some cases.
|
||||
|
||||
|
||||
## [3.2.4] - 2014-12-19
|
||||
### Fixed
|
||||
- Fixed resolving of !!null tag on an empty node.
|
||||
|
||||
|
||||
## [3.2.3] - 2014-11-08
|
||||
### Fixed
|
||||
- Implemented dumping of objects with circular and cross references.
|
||||
- Partially fixed aliasing of constructed objects. (see issue #141 for details)
|
||||
|
||||
|
||||
## [3.2.2] - 2014-09-07
|
||||
### Fixed
|
||||
- Fixed infinite loop on unindented block scalars.
|
||||
- Rewritten base64 encode/decode in binary type, to keep code licence clear.
|
||||
|
||||
|
||||
## [3.2.1] - 2014-08-24
|
||||
### Fixed
|
||||
- Nothig new. Just fix npm publish error.
|
||||
|
||||
|
||||
## [3.2.0] - 2014-08-24
|
||||
### Added
|
||||
- Added input piping support to CLI.
|
||||
|
||||
### Fixed
|
||||
- Fixed typo, that could cause hand on initial indent (#139).
|
||||
|
||||
|
||||
## [3.1.0] - 2014-07-07
|
||||
### Changed
|
||||
- 1.5x-2x speed boost.
|
||||
- Removed deprecated `require('xxx.yml')` support.
|
||||
- Significant code cleanup and refactoring.
|
||||
- Internal API changed. If you used custom types - see updated examples.
|
||||
Others are not affected.
|
||||
- Even if the input string has no trailing line break character,
|
||||
it will be parsed as if it has one.
|
||||
- Added benchmark scripts.
|
||||
- Moved bower files to /dist folder
|
||||
- Bugfixes.
|
||||
|
||||
|
||||
## [3.0.2] - 2014-02-27
|
||||
### Fixed
|
||||
- Fixed bug: "constructor" string parsed as `null`.
|
||||
|
||||
|
||||
## [3.0.1] - 2013-12-22
|
||||
### Fixed
|
||||
- Fixed parsing of literal scalars. (issue #108)
|
||||
- Prevented adding unnecessary spaces in object dumps. (issue #68)
|
||||
- Fixed dumping of objects with very long (> 1024 in length) keys.
|
||||
|
||||
|
||||
## [3.0.0] - 2013-12-16
|
||||
### Changed
|
||||
- Refactored code. Changed API for custom types.
|
||||
- Removed output colors in CLI, dump json by default.
|
||||
- Removed big dependencies from browser version (esprima, buffer). Load `esprima` manually, if `!!js/function` needed. `!!bin` now returns Array in browser
|
||||
- AMD support.
|
||||
- Don't quote dumped strings because of `-` & `?` (if not first char).
|
||||
- __Deprecated__ loading yaml files via `require()`, as not recommended
|
||||
behaviour for node.
|
||||
|
||||
|
||||
## [2.1.3] - 2013-10-16
|
||||
### Fixed
|
||||
- Fix wrong loading of empty block scalars.
|
||||
|
||||
|
||||
## [2.1.2] - 2013-10-07
|
||||
### Fixed
|
||||
- Fix unwanted line breaks in folded scalars.
|
||||
|
||||
|
||||
## [2.1.1] - 2013-10-02
|
||||
### Fixed
|
||||
- Dumper now respects deprecated booleans syntax from YAML 1.0/1.1
|
||||
- Fixed reader bug in JSON-like sequences/mappings.
|
||||
|
||||
|
||||
## [2.1.0] - 2013-06-05
|
||||
### Added
|
||||
- Add standard YAML schemas: Failsafe (`FAILSAFE_SCHEMA`),
|
||||
JSON (`JSON_SCHEMA`) and Core (`CORE_SCHEMA`).
|
||||
- Add `skipInvalid` dumper option.
|
||||
|
||||
### Changed
|
||||
- Rename `DEFAULT_SCHEMA` to `DEFAULT_FULL_SCHEMA`
|
||||
and `SAFE_SCHEMA` to `DEFAULT_SAFE_SCHEMA`.
|
||||
- Use `safeLoad` for `require` extension.
|
||||
|
||||
### Fixed
|
||||
- Bug fix: export `NIL` constant from the public interface.
|
||||
|
||||
|
||||
## [2.0.5] - 2013-04-26
|
||||
### Security
|
||||
- Close security issue in !!js/function constructor.
|
||||
Big thanks to @nealpoole for security audit.
|
||||
|
||||
|
||||
## [2.0.4] - 2013-04-08
|
||||
### Changed
|
||||
- Updated .npmignore to reduce package size
|
||||
|
||||
|
||||
## [2.0.3] - 2013-02-26
|
||||
### Fixed
|
||||
- Fixed dumping of empty arrays ans objects. ([] and {} instead of null)
|
||||
|
||||
|
||||
## [2.0.2] - 2013-02-15
|
||||
### Fixed
|
||||
- Fixed input validation: tabs are printable characters.
|
||||
|
||||
|
||||
## [2.0.1] - 2013-02-09
|
||||
### Fixed
|
||||
- Fixed error, when options not passed to function cass
|
||||
|
||||
|
||||
## [2.0.0] - 2013-02-09
|
||||
### Changed
|
||||
- Full rewrite. New architecture. Fast one-stage parsing.
|
||||
- Changed custom types API.
|
||||
- Added YAML dumper.
|
||||
|
||||
|
||||
## [1.0.3] - 2012-11-05
|
||||
### Fixed
|
||||
- Fixed utf-8 files loading.
|
||||
|
||||
|
||||
## [1.0.2] - 2012-08-02
|
||||
### Fixed
|
||||
- Pull out hand-written shims. Use ES5-Shims for old browsers support. See #44.
|
||||
- Fix timstamps incorectly parsed in local time when no time part specified.
|
||||
|
||||
|
||||
## [1.0.1] - 2012-07-07
|
||||
### Fixed
|
||||
- Fixes `TypeError: 'undefined' is not an object` under Safari. Thanks Phuong.
|
||||
- Fix timestamps incorrectly parsed in local time. Thanks @caolan. Closes #46.
|
||||
|
||||
|
||||
## [1.0.0] - 2012-07-01
|
||||
### Changed
|
||||
- `y`, `yes`, `n`, `no`, `on`, `off` are not converted to Booleans anymore.
|
||||
Fixes #42.
|
||||
- `require(filename)` now returns a single document and throws an Error if
|
||||
file contains more than one document.
|
||||
- CLI was merged back from js-yaml.bin
|
||||
|
||||
|
||||
## [0.3.7] - 2012-02-28
|
||||
### Fixed
|
||||
- Fix export of `addConstructor()`. Closes #39.
|
||||
|
||||
|
||||
## [0.3.6] - 2012-02-22
|
||||
### Changed
|
||||
- Removed AMD parts - too buggy to use. Need help to rewrite from scratch
|
||||
|
||||
### Fixed
|
||||
- Removed YUI compressor warning (renamed `double` variable). Closes #40.
|
||||
|
||||
|
||||
## [0.3.5] - 2012-01-10
|
||||
### Fixed
|
||||
- Workagound for .npmignore fuckup under windows. Thanks to airportyh.
|
||||
|
||||
|
||||
## [0.3.4] - 2011-12-24
|
||||
### Fixed
|
||||
- Fixes str[] for oldIEs support.
|
||||
- Adds better has change support for browserified demo.
|
||||
- improves compact output of Error. Closes #33.
|
||||
|
||||
|
||||
## [0.3.3] - 2011-12-20
|
||||
### Added
|
||||
- adds `compact` stringification of Errors.
|
||||
|
||||
### Changed
|
||||
- jsyaml executable moved to separate module.
|
||||
|
||||
|
||||
## [0.3.2] - 2011-12-16
|
||||
### Added
|
||||
- Added jsyaml executable.
|
||||
- Added !!js/function support. Closes #12.
|
||||
|
||||
### Fixed
|
||||
- Fixes ug with block style scalars. Closes #26.
|
||||
- All sources are passing JSLint now.
|
||||
- Fixes bug in Safari. Closes #28.
|
||||
- Fixes bug in Opers. Closes #29.
|
||||
- Improves browser support. Closes #20.
|
||||
|
||||
|
||||
## [0.3.1] - 2011-11-18
|
||||
### Added
|
||||
- Added AMD support for browserified version.
|
||||
- Added permalinks for online demo YAML snippets. Now we have YPaste service, lol.
|
||||
- Added !!js/regexp and !!js/undefined types. Partially solves #12.
|
||||
|
||||
### Changed
|
||||
- Wrapped browserified js-yaml into closure.
|
||||
|
||||
### Fixed
|
||||
- Fixed the resolvement of non-specific tags. Closes #17.
|
||||
- Fixed !!set mapping.
|
||||
- Fixed month parse in dates. Closes #19.
|
||||
|
||||
|
||||
## [0.3.0] - 2011-11-09
|
||||
### Added
|
||||
- Added browserified version. Closes #13.
|
||||
- Added live demo of browserified version.
|
||||
- Ported some of the PyYAML tests. See #14.
|
||||
|
||||
### Fixed
|
||||
- Removed JS.Class dependency. Closes #3.
|
||||
- Fixed timestamp bug when fraction was given.
|
||||
|
||||
|
||||
## [0.2.2] - 2011-11-06
|
||||
### Fixed
|
||||
- Fixed crash on docs without ---. Closes #8.
|
||||
- Fixed multiline string parse
|
||||
- Fixed tests/comments for using array as key
|
||||
|
||||
|
||||
## [0.2.1] - 2011-11-02
|
||||
### Fixed
|
||||
- Fixed short file read (<4k). Closes #9.
|
||||
|
||||
|
||||
## [0.2.0] - 2011-11-02
|
||||
### Changed
|
||||
- First public release
|
||||
|
||||
|
||||
[3.14.1]: https://github.com/nodeca/js-yaml/compare/3.14.0...3.14.1
|
||||
[3.14.0]: https://github.com/nodeca/js-yaml/compare/3.13.1...3.14.0
|
||||
[3.13.1]: https://github.com/nodeca/js-yaml/compare/3.13.0...3.13.1
|
||||
[3.13.0]: https://github.com/nodeca/js-yaml/compare/3.12.2...3.13.0
|
||||
[3.12.2]: https://github.com/nodeca/js-yaml/compare/3.12.1...3.12.2
|
||||
[3.12.1]: https://github.com/nodeca/js-yaml/compare/3.12.0...3.12.1
|
||||
[3.12.0]: https://github.com/nodeca/js-yaml/compare/3.11.0...3.12.0
|
||||
[3.11.0]: https://github.com/nodeca/js-yaml/compare/3.10.0...3.11.0
|
||||
[3.10.0]: https://github.com/nodeca/js-yaml/compare/3.9.1...3.10.0
|
||||
[3.9.1]: https://github.com/nodeca/js-yaml/compare/3.9.0...3.9.1
|
||||
[3.9.0]: https://github.com/nodeca/js-yaml/compare/3.8.4...3.9.0
|
||||
[3.8.4]: https://github.com/nodeca/js-yaml/compare/3.8.3...3.8.4
|
||||
[3.8.3]: https://github.com/nodeca/js-yaml/compare/3.8.2...3.8.3
|
||||
[3.8.2]: https://github.com/nodeca/js-yaml/compare/3.8.1...3.8.2
|
||||
[3.8.1]: https://github.com/nodeca/js-yaml/compare/3.8.0...3.8.1
|
||||
[3.8.0]: https://github.com/nodeca/js-yaml/compare/3.7.0...3.8.0
|
||||
[3.7.0]: https://github.com/nodeca/js-yaml/compare/3.6.1...3.7.0
|
||||
[3.6.1]: https://github.com/nodeca/js-yaml/compare/3.6.0...3.6.1
|
||||
[3.6.0]: https://github.com/nodeca/js-yaml/compare/3.5.5...3.6.0
|
||||
[3.5.5]: https://github.com/nodeca/js-yaml/compare/3.5.4...3.5.5
|
||||
[3.5.4]: https://github.com/nodeca/js-yaml/compare/3.5.3...3.5.4
|
||||
[3.5.3]: https://github.com/nodeca/js-yaml/compare/3.5.2...3.5.3
|
||||
[3.5.2]: https://github.com/nodeca/js-yaml/compare/3.5.1...3.5.2
|
||||
[3.5.1]: https://github.com/nodeca/js-yaml/compare/3.5.0...3.5.1
|
||||
[3.5.0]: https://github.com/nodeca/js-yaml/compare/3.4.6...3.5.0
|
||||
[3.4.6]: https://github.com/nodeca/js-yaml/compare/3.4.5...3.4.6
|
||||
[3.4.5]: https://github.com/nodeca/js-yaml/compare/3.4.4...3.4.5
|
||||
[3.4.4]: https://github.com/nodeca/js-yaml/compare/3.4.3...3.4.4
|
||||
[3.4.3]: https://github.com/nodeca/js-yaml/compare/3.4.2...3.4.3
|
||||
[3.4.2]: https://github.com/nodeca/js-yaml/compare/3.4.1...3.4.2
|
||||
[3.4.1]: https://github.com/nodeca/js-yaml/compare/3.4.0...3.4.1
|
||||
[3.4.0]: https://github.com/nodeca/js-yaml/compare/3.3.1...3.4.0
|
||||
[3.3.1]: https://github.com/nodeca/js-yaml/compare/3.3.0...3.3.1
|
||||
[3.3.0]: https://github.com/nodeca/js-yaml/compare/3.2.7...3.3.0
|
||||
[3.2.7]: https://github.com/nodeca/js-yaml/compare/3.2.6...3.2.7
|
||||
[3.2.6]: https://github.com/nodeca/js-yaml/compare/3.2.5...3.2.6
|
||||
[3.2.5]: https://github.com/nodeca/js-yaml/compare/3.2.4...3.2.5
|
||||
[3.2.4]: https://github.com/nodeca/js-yaml/compare/3.2.3...3.2.4
|
||||
[3.2.3]: https://github.com/nodeca/js-yaml/compare/3.2.2...3.2.3
|
||||
[3.2.2]: https://github.com/nodeca/js-yaml/compare/3.2.1...3.2.2
|
||||
[3.2.1]: https://github.com/nodeca/js-yaml/compare/3.2.0...3.2.1
|
||||
[3.2.0]: https://github.com/nodeca/js-yaml/compare/3.1.0...3.2.0
|
||||
[3.1.0]: https://github.com/nodeca/js-yaml/compare/3.0.2...3.1.0
|
||||
[3.0.2]: https://github.com/nodeca/js-yaml/compare/3.0.1...3.0.2
|
||||
[3.0.1]: https://github.com/nodeca/js-yaml/compare/3.0.0...3.0.1
|
||||
[3.0.0]: https://github.com/nodeca/js-yaml/compare/2.1.3...3.0.0
|
||||
[2.1.3]: https://github.com/nodeca/js-yaml/compare/2.1.2...2.1.3
|
||||
[2.1.2]: https://github.com/nodeca/js-yaml/compare/2.1.1...2.1.2
|
||||
[2.1.1]: https://github.com/nodeca/js-yaml/compare/2.1.0...2.1.1
|
||||
[2.1.0]: https://github.com/nodeca/js-yaml/compare/2.0.5...2.1.0
|
||||
[2.0.5]: https://github.com/nodeca/js-yaml/compare/2.0.4...2.0.5
|
||||
[2.0.4]: https://github.com/nodeca/js-yaml/compare/2.0.3...2.0.4
|
||||
[2.0.3]: https://github.com/nodeca/js-yaml/compare/2.0.2...2.0.3
|
||||
[2.0.2]: https://github.com/nodeca/js-yaml/compare/2.0.1...2.0.2
|
||||
[2.0.1]: https://github.com/nodeca/js-yaml/compare/2.0.0...2.0.1
|
||||
[2.0.0]: https://github.com/nodeca/js-yaml/compare/1.0.3...2.0.0
|
||||
[1.0.3]: https://github.com/nodeca/js-yaml/compare/1.0.2...1.0.3
|
||||
[1.0.2]: https://github.com/nodeca/js-yaml/compare/1.0.1...1.0.2
|
||||
[1.0.1]: https://github.com/nodeca/js-yaml/compare/1.0.0...1.0.1
|
||||
[1.0.0]: https://github.com/nodeca/js-yaml/compare/0.3.7...1.0.0
|
||||
[0.3.7]: https://github.com/nodeca/js-yaml/compare/0.3.6...0.3.7
|
||||
[0.3.6]: https://github.com/nodeca/js-yaml/compare/0.3.5...0.3.6
|
||||
[0.3.5]: https://github.com/nodeca/js-yaml/compare/0.3.4...0.3.5
|
||||
[0.3.4]: https://github.com/nodeca/js-yaml/compare/0.3.3...0.3.4
|
||||
[0.3.3]: https://github.com/nodeca/js-yaml/compare/0.3.2...0.3.3
|
||||
[0.3.2]: https://github.com/nodeca/js-yaml/compare/0.3.1...0.3.2
|
||||
[0.3.1]: https://github.com/nodeca/js-yaml/compare/0.3.0...0.3.1
|
||||
[0.3.0]: https://github.com/nodeca/js-yaml/compare/0.2.2...0.3.0
|
||||
[0.2.2]: https://github.com/nodeca/js-yaml/compare/0.2.1...0.2.2
|
||||
[0.2.1]: https://github.com/nodeca/js-yaml/compare/0.2.0...0.2.1
|
||||
[0.2.0]: https://github.com/nodeca/js-yaml/releases/tag/0.2.0
|
21
node_modules/@eslint/eslintrc/node_modules/js-yaml/LICENSE
сгенерированный
поставляемый
Normal file
21
node_modules/@eslint/eslintrc/node_modules/js-yaml/LICENSE
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,21 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (C) 2011-2015 by Vitaly Puzrin
|
||||
|
||||
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.
|
299
node_modules/@eslint/eslintrc/node_modules/js-yaml/README.md
сгенерированный
поставляемый
Normal file
299
node_modules/@eslint/eslintrc/node_modules/js-yaml/README.md
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,299 @@
|
|||
JS-YAML - YAML 1.2 parser / writer for JavaScript
|
||||
=================================================
|
||||
|
||||
[![Build Status](https://travis-ci.org/nodeca/js-yaml.svg?branch=master)](https://travis-ci.org/nodeca/js-yaml)
|
||||
[![NPM version](https://img.shields.io/npm/v/js-yaml.svg)](https://www.npmjs.org/package/js-yaml)
|
||||
|
||||
__[Online Demo](http://nodeca.github.com/js-yaml/)__
|
||||
|
||||
|
||||
This is an implementation of [YAML](http://yaml.org/), a human-friendly data
|
||||
serialization language. Started as [PyYAML](http://pyyaml.org/) port, it was
|
||||
completely rewritten from scratch. Now it's very fast, and supports 1.2 spec.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
### YAML module for node.js
|
||||
|
||||
```
|
||||
npm install js-yaml
|
||||
```
|
||||
|
||||
|
||||
### CLI executable
|
||||
|
||||
If you want to inspect your YAML files from CLI, install js-yaml globally:
|
||||
|
||||
```
|
||||
npm install -g js-yaml
|
||||
```
|
||||
|
||||
#### Usage
|
||||
|
||||
```
|
||||
usage: js-yaml [-h] [-v] [-c] [-t] file
|
||||
|
||||
Positional arguments:
|
||||
file File with YAML document(s)
|
||||
|
||||
Optional arguments:
|
||||
-h, --help Show this help message and exit.
|
||||
-v, --version Show program's version number and exit.
|
||||
-c, --compact Display errors in compact mode
|
||||
-t, --trace Show stack trace on error
|
||||
```
|
||||
|
||||
|
||||
### Bundled YAML library for browsers
|
||||
|
||||
``` html
|
||||
<!-- esprima required only for !!js/function -->
|
||||
<script src="esprima.js"></script>
|
||||
<script src="js-yaml.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
var doc = jsyaml.load('greeting: hello\nname: world');
|
||||
</script>
|
||||
```
|
||||
|
||||
Browser support was done mostly for the online demo. If you find any errors - feel
|
||||
free to send pull requests with fixes. Also note, that IE and other old browsers
|
||||
needs [es5-shims](https://github.com/kriskowal/es5-shim) to operate.
|
||||
|
||||
Notes:
|
||||
|
||||
1. We have no resources to support browserified version. Don't expect it to be
|
||||
well tested. Don't expect fast fixes if something goes wrong there.
|
||||
2. `!!js/function` in browser bundle will not work by default. If you really need
|
||||
it - load `esprima` parser first (via amd or directly).
|
||||
3. `!!bin` in browser will return `Array`, because browsers do not support
|
||||
node.js `Buffer` and adding Buffer shims is completely useless on practice.
|
||||
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
Here we cover the most 'useful' methods. If you need advanced details (creating
|
||||
your own tags), see [wiki](https://github.com/nodeca/js-yaml/wiki) and
|
||||
[examples](https://github.com/nodeca/js-yaml/tree/master/examples) for more
|
||||
info.
|
||||
|
||||
``` javascript
|
||||
const yaml = require('js-yaml');
|
||||
const fs = require('fs');
|
||||
|
||||
// Get document, or throw exception on error
|
||||
try {
|
||||
const doc = yaml.safeLoad(fs.readFileSync('/home/ixti/example.yml', 'utf8'));
|
||||
console.log(doc);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### safeLoad (string [ , options ])
|
||||
|
||||
**Recommended loading way.** Parses `string` as single YAML document. Returns either a
|
||||
plain object, a string or `undefined`, or throws `YAMLException` on error. By default, does
|
||||
not support regexps, functions and undefined. This method is safe for untrusted data.
|
||||
|
||||
options:
|
||||
|
||||
- `filename` _(default: null)_ - string to be used as a file path in
|
||||
error/warning messages.
|
||||
- `onWarning` _(default: null)_ - function to call on warning messages.
|
||||
Loader will call this function with an instance of `YAMLException` for each warning.
|
||||
- `schema` _(default: `DEFAULT_SAFE_SCHEMA`)_ - specifies a schema to use.
|
||||
- `FAILSAFE_SCHEMA` - only strings, arrays and plain objects:
|
||||
http://www.yaml.org/spec/1.2/spec.html#id2802346
|
||||
- `JSON_SCHEMA` - all JSON-supported types:
|
||||
http://www.yaml.org/spec/1.2/spec.html#id2803231
|
||||
- `CORE_SCHEMA` - same as `JSON_SCHEMA`:
|
||||
http://www.yaml.org/spec/1.2/spec.html#id2804923
|
||||
- `DEFAULT_SAFE_SCHEMA` - all supported YAML types, without unsafe ones
|
||||
(`!!js/undefined`, `!!js/regexp` and `!!js/function`):
|
||||
http://yaml.org/type/
|
||||
- `DEFAULT_FULL_SCHEMA` - all supported YAML types.
|
||||
- `json` _(default: false)_ - compatibility with JSON.parse behaviour. If true, then duplicate keys in a mapping will override values rather than throwing an error.
|
||||
|
||||
NOTE: This function **does not** understand multi-document sources, it throws
|
||||
exception on those.
|
||||
|
||||
NOTE: JS-YAML **does not** support schema-specific tag resolution restrictions.
|
||||
So, the JSON schema is not as strictly defined in the YAML specification.
|
||||
It allows numbers in any notation, use `Null` and `NULL` as `null`, etc.
|
||||
The core schema also has no such restrictions. It allows binary notation for integers.
|
||||
|
||||
|
||||
### load (string [ , options ])
|
||||
|
||||
**Use with care with untrusted sources**. The same as `safeLoad()` but uses
|
||||
`DEFAULT_FULL_SCHEMA` by default - adds some JavaScript-specific types:
|
||||
`!!js/function`, `!!js/regexp` and `!!js/undefined`. For untrusted sources, you
|
||||
must additionally validate object structure to avoid injections:
|
||||
|
||||
``` javascript
|
||||
const untrusted_code = '"toString": !<tag:yaml.org,2002:js/function> "function (){very_evil_thing();}"';
|
||||
|
||||
// I'm just converting that string, what could possibly go wrong?
|
||||
require('js-yaml').load(untrusted_code) + ''
|
||||
```
|
||||
|
||||
|
||||
### safeLoadAll (string [, iterator] [, options ])
|
||||
|
||||
Same as `safeLoad()`, but understands multi-document sources. Applies
|
||||
`iterator` to each document if specified, or returns array of documents.
|
||||
|
||||
``` javascript
|
||||
const yaml = require('js-yaml');
|
||||
|
||||
yaml.safeLoadAll(data, function (doc) {
|
||||
console.log(doc);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### loadAll (string [, iterator] [ , options ])
|
||||
|
||||
Same as `safeLoadAll()` but uses `DEFAULT_FULL_SCHEMA` by default.
|
||||
|
||||
|
||||
### safeDump (object [ , options ])
|
||||
|
||||
Serializes `object` as a YAML document. Uses `DEFAULT_SAFE_SCHEMA`, so it will
|
||||
throw an exception if you try to dump regexps or functions. However, you can
|
||||
disable exceptions by setting the `skipInvalid` option to `true`.
|
||||
|
||||
options:
|
||||
|
||||
- `indent` _(default: 2)_ - indentation width to use (in spaces).
|
||||
- `noArrayIndent` _(default: false)_ - when true, will not add an indentation level to array elements
|
||||
- `skipInvalid` _(default: false)_ - do not throw on invalid types (like function
|
||||
in the safe schema) and skip pairs and single values with such types.
|
||||
- `flowLevel` (default: -1) - specifies level of nesting, when to switch from
|
||||
block to flow style for collections. -1 means block style everwhere
|
||||
- `styles` - "tag" => "style" map. Each tag may have own set of styles.
|
||||
- `schema` _(default: `DEFAULT_SAFE_SCHEMA`)_ specifies a schema to use.
|
||||
- `sortKeys` _(default: `false`)_ - if `true`, sort keys when dumping YAML. If a
|
||||
function, use the function to sort the keys.
|
||||
- `lineWidth` _(default: `80`)_ - set max line width.
|
||||
- `noRefs` _(default: `false`)_ - if `true`, don't convert duplicate objects into references
|
||||
- `noCompatMode` _(default: `false`)_ - if `true` don't try to be compatible with older
|
||||
yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1
|
||||
- `condenseFlow` _(default: `false`)_ - if `true` flow sequences will be condensed, omitting the space between `a, b`. Eg. `'[a,b]'`, and omitting the space between `key: value` and quoting the key. Eg. `'{"a":b}'` Can be useful when using yaml for pretty URL query params as spaces are %-encoded.
|
||||
|
||||
The following table show availlable styles (e.g. "canonical",
|
||||
"binary"...) available for each tag (.e.g. !!null, !!int ...). Yaml
|
||||
output is shown on the right side after `=>` (default setting) or `->`:
|
||||
|
||||
``` none
|
||||
!!null
|
||||
"canonical" -> "~"
|
||||
"lowercase" => "null"
|
||||
"uppercase" -> "NULL"
|
||||
"camelcase" -> "Null"
|
||||
|
||||
!!int
|
||||
"binary" -> "0b1", "0b101010", "0b1110001111010"
|
||||
"octal" -> "01", "052", "016172"
|
||||
"decimal" => "1", "42", "7290"
|
||||
"hexadecimal" -> "0x1", "0x2A", "0x1C7A"
|
||||
|
||||
!!bool
|
||||
"lowercase" => "true", "false"
|
||||
"uppercase" -> "TRUE", "FALSE"
|
||||
"camelcase" -> "True", "False"
|
||||
|
||||
!!float
|
||||
"lowercase" => ".nan", '.inf'
|
||||
"uppercase" -> ".NAN", '.INF'
|
||||
"camelcase" -> ".NaN", '.Inf'
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
``` javascript
|
||||
safeDump (object, {
|
||||
'styles': {
|
||||
'!!null': 'canonical' // dump null as ~
|
||||
},
|
||||
'sortKeys': true // sort object keys
|
||||
});
|
||||
```
|
||||
|
||||
### dump (object [ , options ])
|
||||
|
||||
Same as `safeDump()` but without limits (uses `DEFAULT_FULL_SCHEMA` by default).
|
||||
|
||||
|
||||
Supported YAML types
|
||||
--------------------
|
||||
|
||||
The list of standard YAML tags and corresponding JavaScipt types. See also
|
||||
[YAML tag discussion](http://pyyaml.org/wiki/YAMLTagDiscussion) and
|
||||
[YAML types repository](http://yaml.org/type/).
|
||||
|
||||
```
|
||||
!!null '' # null
|
||||
!!bool 'yes' # bool
|
||||
!!int '3...' # number
|
||||
!!float '3.14...' # number
|
||||
!!binary '...base64...' # buffer
|
||||
!!timestamp 'YYYY-...' # date
|
||||
!!omap [ ... ] # array of key-value pairs
|
||||
!!pairs [ ... ] # array or array pairs
|
||||
!!set { ... } # array of objects with given keys and null values
|
||||
!!str '...' # string
|
||||
!!seq [ ... ] # array
|
||||
!!map { ... } # object
|
||||
```
|
||||
|
||||
**JavaScript-specific tags**
|
||||
|
||||
```
|
||||
!!js/regexp /pattern/gim # RegExp
|
||||
!!js/undefined '' # Undefined
|
||||
!!js/function 'function () {...}' # Function
|
||||
```
|
||||
|
||||
Caveats
|
||||
-------
|
||||
|
||||
Note, that you use arrays or objects as key in JS-YAML. JS does not allow objects
|
||||
or arrays as keys, and stringifies (by calling `toString()` method) them at the
|
||||
moment of adding them.
|
||||
|
||||
``` yaml
|
||||
---
|
||||
? [ foo, bar ]
|
||||
: - baz
|
||||
? { foo: bar }
|
||||
: - baz
|
||||
- baz
|
||||
```
|
||||
|
||||
``` javascript
|
||||
{ "foo,bar": ["baz"], "[object Object]": ["baz", "baz"] }
|
||||
```
|
||||
|
||||
Also, reading of properties on implicit block mapping keys is not supported yet.
|
||||
So, the following YAML document cannot be loaded.
|
||||
|
||||
``` yaml
|
||||
&anchor foo:
|
||||
foo: bar
|
||||
*anchor: duplicate key
|
||||
baz: bat
|
||||
*anchor: duplicate key
|
||||
```
|
||||
|
||||
|
||||
js-yaml for enterprise
|
||||
----------------------
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of js-yaml and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-js-yaml?utm_source=npm-js-yaml&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
132
node_modules/@eslint/eslintrc/node_modules/js-yaml/bin/js-yaml.js
сгенерированный
поставляемый
Executable file
132
node_modules/@eslint/eslintrc/node_modules/js-yaml/bin/js-yaml.js
сгенерированный
поставляемый
Executable file
|
@ -0,0 +1,132 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
|
||||
'use strict';
|
||||
|
||||
/*eslint-disable no-console*/
|
||||
|
||||
|
||||
// stdlib
|
||||
var fs = require('fs');
|
||||
|
||||
|
||||
// 3rd-party
|
||||
var argparse = require('argparse');
|
||||
|
||||
|
||||
// internal
|
||||
var yaml = require('..');
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
var cli = new argparse.ArgumentParser({
|
||||
prog: 'js-yaml',
|
||||
version: require('../package.json').version,
|
||||
addHelp: true
|
||||
});
|
||||
|
||||
|
||||
cli.addArgument([ '-c', '--compact' ], {
|
||||
help: 'Display errors in compact mode',
|
||||
action: 'storeTrue'
|
||||
});
|
||||
|
||||
|
||||
// deprecated (not needed after we removed output colors)
|
||||
// option suppressed, but not completely removed for compatibility
|
||||
cli.addArgument([ '-j', '--to-json' ], {
|
||||
help: argparse.Const.SUPPRESS,
|
||||
dest: 'json',
|
||||
action: 'storeTrue'
|
||||
});
|
||||
|
||||
|
||||
cli.addArgument([ '-t', '--trace' ], {
|
||||
help: 'Show stack trace on error',
|
||||
action: 'storeTrue'
|
||||
});
|
||||
|
||||
cli.addArgument([ 'file' ], {
|
||||
help: 'File to read, utf-8 encoded without BOM',
|
||||
nargs: '?',
|
||||
defaultValue: '-'
|
||||
});
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
var options = cli.parseArgs();
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function readFile(filename, encoding, callback) {
|
||||
if (options.file === '-') {
|
||||
// read from stdin
|
||||
|
||||
var chunks = [];
|
||||
|
||||
process.stdin.on('data', function (chunk) {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
|
||||
process.stdin.on('end', function () {
|
||||
return callback(null, Buffer.concat(chunks).toString(encoding));
|
||||
});
|
||||
} else {
|
||||
fs.readFile(filename, encoding, callback);
|
||||
}
|
||||
}
|
||||
|
||||
readFile(options.file, 'utf8', function (error, input) {
|
||||
var output, isYaml;
|
||||
|
||||
if (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
console.error('File not found: ' + options.file);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
console.error(
|
||||
options.trace && error.stack ||
|
||||
error.message ||
|
||||
String(error));
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
output = JSON.parse(input);
|
||||
isYaml = false;
|
||||
} catch (err) {
|
||||
if (err instanceof SyntaxError) {
|
||||
try {
|
||||
output = [];
|
||||
yaml.loadAll(input, function (doc) { output.push(doc); }, {});
|
||||
isYaml = true;
|
||||
|
||||
if (output.length === 0) output = null;
|
||||
else if (output.length === 1) output = output[0];
|
||||
|
||||
} catch (e) {
|
||||
if (options.trace && err.stack) console.error(e.stack);
|
||||
else console.error(e.toString(options.compact));
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
console.error(
|
||||
options.trace && err.stack ||
|
||||
err.message ||
|
||||
String(err));
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (isYaml) console.log(JSON.stringify(output, null, ' '));
|
||||
else console.log(yaml.dump(output));
|
||||
});
|
3989
node_modules/@eslint/eslintrc/node_modules/js-yaml/dist/js-yaml.js
сгенерированный
поставляемый
Normal file
3989
node_modules/@eslint/eslintrc/node_modules/js-yaml/dist/js-yaml.js
сгенерированный
поставляемый
Normal file
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
1
node_modules/@eslint/eslintrc/node_modules/js-yaml/dist/js-yaml.min.js
сгенерированный
поставляемый
Normal file
1
node_modules/@eslint/eslintrc/node_modules/js-yaml/dist/js-yaml.min.js
сгенерированный
поставляемый
Normal file
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
7
node_modules/@eslint/eslintrc/node_modules/js-yaml/index.js
сгенерированный
поставляемый
Normal file
7
node_modules/@eslint/eslintrc/node_modules/js-yaml/index.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
var yaml = require('./lib/js-yaml.js');
|
||||
|
||||
|
||||
module.exports = yaml;
|
0
node_modules/js-yaml/lib/js-yaml.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/common.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/common.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/common.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/common.js
сгенерированный
поставляемый
37
node_modules/js-yaml/lib/js-yaml/dumper.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/dumper.js
сгенерированный
поставляемый
37
node_modules/js-yaml/lib/js-yaml/dumper.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/dumper.js
сгенерированный
поставляемый
|
@ -12,6 +12,7 @@ var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|||
|
||||
var CHAR_TAB = 0x09; /* Tab */
|
||||
var CHAR_LINE_FEED = 0x0A; /* LF */
|
||||
var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
|
||||
var CHAR_SPACE = 0x20; /* Space */
|
||||
var CHAR_EXCLAMATION = 0x21; /* ! */
|
||||
var CHAR_DOUBLE_QUOTE = 0x22; /* " */
|
||||
|
@ -23,6 +24,7 @@ var CHAR_ASTERISK = 0x2A; /* * */
|
|||
var CHAR_COMMA = 0x2C; /* , */
|
||||
var CHAR_MINUS = 0x2D; /* - */
|
||||
var CHAR_COLON = 0x3A; /* : */
|
||||
var CHAR_EQUALS = 0x3D; /* = */
|
||||
var CHAR_GREATER_THAN = 0x3E; /* > */
|
||||
var CHAR_QUESTION = 0x3F; /* ? */
|
||||
var CHAR_COMMERCIAL_AT = 0x40; /* @ */
|
||||
|
@ -188,8 +190,23 @@ function isPrintable(c) {
|
|||
|| (0x10000 <= c && c <= 0x10FFFF);
|
||||
}
|
||||
|
||||
// [34] ns-char ::= nb-char - s-white
|
||||
// [27] nb-char ::= c-printable - b-char - c-byte-order-mark
|
||||
// [26] b-char ::= b-line-feed | b-carriage-return
|
||||
// [24] b-line-feed ::= #xA /* LF */
|
||||
// [25] b-carriage-return ::= #xD /* CR */
|
||||
// [3] c-byte-order-mark ::= #xFEFF
|
||||
function isNsChar(c) {
|
||||
return isPrintable(c) && !isWhitespace(c)
|
||||
// byte-order-mark
|
||||
&& c !== 0xFEFF
|
||||
// b-char
|
||||
&& c !== CHAR_CARRIAGE_RETURN
|
||||
&& c !== CHAR_LINE_FEED;
|
||||
}
|
||||
|
||||
// Simplified test for values allowed after the first character in plain style.
|
||||
function isPlainSafe(c) {
|
||||
function isPlainSafe(c, prev) {
|
||||
// Uses a subset of nb-char - c-flow-indicator - ":" - "#"
|
||||
// where nb-char ::= c-printable - b-char - c-byte-order-mark.
|
||||
return isPrintable(c) && c !== 0xFEFF
|
||||
|
@ -200,8 +217,9 @@ function isPlainSafe(c) {
|
|||
&& c !== CHAR_LEFT_CURLY_BRACKET
|
||||
&& c !== CHAR_RIGHT_CURLY_BRACKET
|
||||
// - ":" - "#"
|
||||
// /* An ns-char preceding */ "#"
|
||||
&& c !== CHAR_COLON
|
||||
&& c !== CHAR_SHARP;
|
||||
&& ((c !== CHAR_SHARP) || (prev && isNsChar(prev)));
|
||||
}
|
||||
|
||||
// Simplified test for values allowed as the first character in plain style.
|
||||
|
@ -220,12 +238,13 @@ function isPlainSafeFirst(c) {
|
|||
&& c !== CHAR_RIGHT_SQUARE_BRACKET
|
||||
&& c !== CHAR_LEFT_CURLY_BRACKET
|
||||
&& c !== CHAR_RIGHT_CURLY_BRACKET
|
||||
// | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"”
|
||||
// | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
|
||||
&& c !== CHAR_SHARP
|
||||
&& c !== CHAR_AMPERSAND
|
||||
&& c !== CHAR_ASTERISK
|
||||
&& c !== CHAR_EXCLAMATION
|
||||
&& c !== CHAR_VERTICAL_LINE
|
||||
&& c !== CHAR_EQUALS
|
||||
&& c !== CHAR_GREATER_THAN
|
||||
&& c !== CHAR_SINGLE_QUOTE
|
||||
&& c !== CHAR_DOUBLE_QUOTE
|
||||
|
@ -256,7 +275,7 @@ var STYLE_PLAIN = 1,
|
|||
// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
|
||||
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
|
||||
var i;
|
||||
var char;
|
||||
var char, prev_char;
|
||||
var hasLineBreak = false;
|
||||
var hasFoldableLine = false; // only checked if shouldTrackWidth
|
||||
var shouldTrackWidth = lineWidth !== -1;
|
||||
|
@ -272,7 +291,8 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te
|
|||
if (!isPrintable(char)) {
|
||||
return STYLE_DOUBLE;
|
||||
}
|
||||
plain = plain && isPlainSafe(char);
|
||||
prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
|
||||
plain = plain && isPlainSafe(char, prev_char);
|
||||
}
|
||||
} else {
|
||||
// Case: block styles permitted.
|
||||
|
@ -291,7 +311,8 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te
|
|||
} else if (!isPrintable(char)) {
|
||||
return STYLE_DOUBLE;
|
||||
}
|
||||
plain = plain && isPlainSafe(char);
|
||||
prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
|
||||
plain = plain && isPlainSafe(char, prev_char);
|
||||
}
|
||||
// in case the end is missing a \n
|
||||
hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
|
||||
|
@ -548,10 +569,12 @@ function writeFlowMapping(state, level, object) {
|
|||
pairBuffer;
|
||||
|
||||
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
||||
pairBuffer = state.condenseFlow ? '"' : '';
|
||||
|
||||
pairBuffer = '';
|
||||
if (index !== 0) pairBuffer += ', ';
|
||||
|
||||
if (state.condenseFlow) pairBuffer += '"';
|
||||
|
||||
objectKey = objectKeyList[index];
|
||||
objectValue = object[objectKey];
|
||||
|
0
node_modules/js-yaml/lib/js-yaml/exception.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/exception.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/exception.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/exception.js
сгенерированный
поставляемый
43
node_modules/js-yaml/lib/js-yaml/loader.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/loader.js
сгенерированный
поставляемый
43
node_modules/js-yaml/lib/js-yaml/loader.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/loader.js
сгенерированный
поставляемый
|
@ -1272,7 +1272,7 @@ function readAlias(state) {
|
|||
|
||||
alias = state.input.slice(_position, state.position);
|
||||
|
||||
if (!state.anchorMap.hasOwnProperty(alias)) {
|
||||
if (!_hasOwnProperty.call(state.anchorMap, alias)) {
|
||||
throwError(state, 'unidentified alias "' + alias + '"');
|
||||
}
|
||||
|
||||
|
@ -1393,13 +1393,19 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
|
|||
|
||||
if (state.tag !== null && state.tag !== '!') {
|
||||
if (state.tag === '?') {
|
||||
// Implicit resolving is not allowed for non-scalar types, and '?'
|
||||
// non-specific tag is only automatically assigned to plain scalars.
|
||||
//
|
||||
// We only need to check kind conformity in case user explicitly assigns '?'
|
||||
// tag, for example like this: "!<?> [0]"
|
||||
//
|
||||
if (state.result !== null && state.kind !== 'scalar') {
|
||||
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
||||
}
|
||||
|
||||
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
||||
type = state.implicitTypes[typeIndex];
|
||||
|
||||
// Implicit resolving is not allowed for non-scalar types, and '?'
|
||||
// non-specific tag is only assigned to plain scalars. So, it isn't
|
||||
// needed to check for 'kind' conformity.
|
||||
|
||||
if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
|
||||
state.result = type.construct(state.result);
|
||||
state.tag = type.tag;
|
||||
|
@ -1563,6 +1569,13 @@ function loadDocuments(input, options) {
|
|||
|
||||
var state = new State(input, options);
|
||||
|
||||
var nullpos = input.indexOf('\0');
|
||||
|
||||
if (nullpos !== -1) {
|
||||
state.position = nullpos;
|
||||
throwError(state, 'null byte is not allowed in input');
|
||||
}
|
||||
|
||||
// Use 0 as string terminator. That significantly simplifies bounds check.
|
||||
state.input += '\0';
|
||||
|
||||
|
@ -1580,13 +1593,18 @@ function loadDocuments(input, options) {
|
|||
|
||||
|
||||
function loadAll(input, iterator, options) {
|
||||
var documents = loadDocuments(input, options), index, length;
|
||||
if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') {
|
||||
options = iterator;
|
||||
iterator = null;
|
||||
}
|
||||
|
||||
var documents = loadDocuments(input, options);
|
||||
|
||||
if (typeof iterator !== 'function') {
|
||||
return documents;
|
||||
}
|
||||
|
||||
for (index = 0, length = documents.length; index < length; index += 1) {
|
||||
for (var index = 0, length = documents.length; index < length; index += 1) {
|
||||
iterator(documents[index]);
|
||||
}
|
||||
}
|
||||
|
@ -1605,12 +1623,13 @@ function load(input, options) {
|
|||
}
|
||||
|
||||
|
||||
function safeLoadAll(input, output, options) {
|
||||
if (typeof output === 'function') {
|
||||
loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
||||
} else {
|
||||
return loadAll(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
||||
function safeLoadAll(input, iterator, options) {
|
||||
if (typeof iterator === 'object' && iterator !== null && typeof options === 'undefined') {
|
||||
options = iterator;
|
||||
iterator = null;
|
||||
}
|
||||
|
||||
return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
||||
}
|
||||
|
||||
|
0
node_modules/js-yaml/lib/js-yaml/mark.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/mark.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/mark.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/mark.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/schema.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/schema.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/schema.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/schema.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/bool.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/bool.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/bool.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/bool.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/int.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/int.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/int.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/int.js
сгенерированный
поставляемый
|
@ -14,7 +14,8 @@ try {
|
|||
var _require = require;
|
||||
esprima = _require('esprima');
|
||||
} catch (_) {
|
||||
/*global window */
|
||||
/* eslint-disable no-redeclare */
|
||||
/* global window */
|
||||
if (typeof window !== 'undefined') esprima = window.esprima;
|
||||
}
|
||||
|
0
node_modules/js-yaml/lib/js-yaml/type/map.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/map.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/map.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/map.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/null.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/null.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/null.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/null.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/omap.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/omap.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/omap.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/omap.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/seq.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/seq.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/seq.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/seq.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/set.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/set.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/set.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/set.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/str.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/str.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/str.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/str.js
сгенерированный
поставляемый
49
node_modules/@eslint/eslintrc/node_modules/js-yaml/package.json
сгенерированный
поставляемый
Normal file
49
node_modules/@eslint/eslintrc/node_modules/js-yaml/package.json
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
"name": "js-yaml",
|
||||
"version": "3.14.1",
|
||||
"description": "YAML 1.2 parser and serializer",
|
||||
"keywords": [
|
||||
"yaml",
|
||||
"parser",
|
||||
"serializer",
|
||||
"pyyaml"
|
||||
],
|
||||
"homepage": "https://github.com/nodeca/js-yaml",
|
||||
"author": "Vladimir Zapparov <dervus.grim@gmail.com>",
|
||||
"contributors": [
|
||||
"Aleksey V Zapparov <ixti@member.fsf.org> (http://www.ixti.net/)",
|
||||
"Vitaly Puzrin <vitaly@rcdesign.ru> (https://github.com/puzrin)",
|
||||
"Martin Grenfell <martin.grenfell@gmail.com> (http://got-ravings.blogspot.com)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "nodeca/js-yaml",
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/",
|
||||
"bin/",
|
||||
"dist/"
|
||||
],
|
||||
"bin": {
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
},
|
||||
"unpkg": "dist/js-yaml.min.js",
|
||||
"jsdelivr": "dist/js-yaml.min.js",
|
||||
"dependencies": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ansi": "^0.3.1",
|
||||
"benchmark": "^2.1.4",
|
||||
"browserify": "^16.2.2",
|
||||
"codemirror": "^5.13.4",
|
||||
"eslint": "^7.0.0",
|
||||
"fast-check": "^1.24.2",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^7.1.2",
|
||||
"uglify-js": "^3.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
}
|
||||
}
|
|
@ -1,185 +1,216 @@
|
|||
1.0.10 / 2018-02-15
|
||||
------------------
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
|
||||
## [2.0.1] - 2020-08-29
|
||||
### Fixed
|
||||
- Fix issue with `process.argv` when used with interpreters (`coffee`, `ts-node`, etc.), #150.
|
||||
|
||||
|
||||
## [2.0.0] - 2020-08-14
|
||||
### Changed
|
||||
- Full rewrite. Now port from python 3.9.0 & more precise following.
|
||||
See [doc](./doc) for difference and migration info.
|
||||
- node.js 10+ required
|
||||
- Removed most of local docs in favour of original ones.
|
||||
|
||||
|
||||
## [1.0.10] - 2018-02-15
|
||||
### Fixed
|
||||
- Use .concat instead of + for arrays, #122.
|
||||
|
||||
|
||||
1.0.9 / 2016-09-29
|
||||
------------------
|
||||
|
||||
## [1.0.9] - 2016-09-29
|
||||
### Changed
|
||||
- Rerelease after 1.0.8 - deps cleanup.
|
||||
|
||||
|
||||
1.0.8 / 2016-09-29
|
||||
------------------
|
||||
|
||||
## [1.0.8] - 2016-09-29
|
||||
### Changed
|
||||
- Maintenance (deps bump, fix node 6.5+ tests, coverage report).
|
||||
|
||||
|
||||
1.0.7 / 2016-03-17
|
||||
------------------
|
||||
|
||||
## [1.0.7] - 2016-03-17
|
||||
### Changed
|
||||
- Teach `addArgument` to accept string arg names. #97, @tomxtobin.
|
||||
|
||||
|
||||
1.0.6 / 2016-02-06
|
||||
------------------
|
||||
|
||||
## [1.0.6] - 2016-02-06
|
||||
### Changed
|
||||
- Maintenance: moved to eslint & updated CS.
|
||||
|
||||
|
||||
1.0.5 / 2016-02-05
|
||||
------------------
|
||||
|
||||
## [1.0.5] - 2016-02-05
|
||||
### Changed
|
||||
- Removed lodash dependency to significantly reduce install size.
|
||||
Thanks to @mourner.
|
||||
|
||||
|
||||
1.0.4 / 2016-01-17
|
||||
------------------
|
||||
|
||||
## [1.0.4] - 2016-01-17
|
||||
### Changed
|
||||
- Maintenance: lodash update to 4.0.0.
|
||||
|
||||
|
||||
1.0.3 / 2015-10-27
|
||||
------------------
|
||||
|
||||
## [1.0.3] - 2015-10-27
|
||||
### Fixed
|
||||
- Fix parse `=` in args: `--examplepath="C:\myfolder\env=x64"`. #84, @CatWithApple.
|
||||
|
||||
|
||||
1.0.2 / 2015-03-22
|
||||
------------------
|
||||
|
||||
## [1.0.2] - 2015-03-22
|
||||
### Changed
|
||||
- Relaxed lodash version dependency.
|
||||
|
||||
|
||||
1.0.1 / 2015-02-20
|
||||
------------------
|
||||
|
||||
## [1.0.1] - 2015-02-20
|
||||
### Changed
|
||||
- Changed dependencies to be compatible with ancient nodejs.
|
||||
|
||||
|
||||
1.0.0 / 2015-02-19
|
||||
------------------
|
||||
|
||||
## [1.0.0] - 2015-02-19
|
||||
### Changed
|
||||
- Maintenance release.
|
||||
- Replaced `underscore` with `lodash`.
|
||||
- Bumped version to 1.0.0 to better reflect semver meaning.
|
||||
- HISTORY.md -> CHANGELOG.md
|
||||
|
||||
|
||||
0.1.16 / 2013-12-01
|
||||
-------------------
|
||||
|
||||
## [0.1.16] - 2013-12-01
|
||||
### Changed
|
||||
- Maintenance release. Updated dependencies and docs.
|
||||
|
||||
|
||||
0.1.15 / 2013-05-13
|
||||
-------------------
|
||||
|
||||
## [0.1.15] - 2013-05-13
|
||||
### Fixed
|
||||
- Fixed #55, @trebor89
|
||||
|
||||
|
||||
0.1.14 / 2013-05-12
|
||||
-------------------
|
||||
|
||||
## [0.1.14] - 2013-05-12
|
||||
### Fixed
|
||||
- Fixed #62, @maxtaco
|
||||
|
||||
|
||||
0.1.13 / 2013-04-08
|
||||
-------------------
|
||||
|
||||
## [0.1.13] - 2013-04-08
|
||||
### Changed
|
||||
- Added `.npmignore` to reduce package size
|
||||
|
||||
|
||||
0.1.12 / 2013-02-10
|
||||
-------------------
|
||||
|
||||
## [0.1.12] - 2013-02-10
|
||||
### Fixed
|
||||
- Fixed conflictHandler (#46), @hpaulj
|
||||
|
||||
|
||||
0.1.11 / 2013-02-07
|
||||
-------------------
|
||||
|
||||
- Multiple bugfixes, @hpaulj
|
||||
## [0.1.11] - 2013-02-07
|
||||
### Added
|
||||
- Added 70+ tests (ported from python), @hpaulj
|
||||
- Added conflictHandler, @applepicke
|
||||
- Added fromfilePrefixChar, @hpaulj
|
||||
|
||||
### Fixed
|
||||
- Multiple bugfixes, @hpaulj
|
||||
|
||||
0.1.10 / 2012-12-30
|
||||
-------------------
|
||||
|
||||
## [0.1.10] - 2012-12-30
|
||||
### Added
|
||||
- Added [mutual exclusion](http://docs.python.org/dev/library/argparse.html#mutual-exclusion)
|
||||
support, thanks to @hpaulj
|
||||
|
||||
### Fixed
|
||||
- Fixed options check for `storeConst` & `appendConst` actions, thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.9 / 2012-12-27
|
||||
------------------
|
||||
|
||||
## [0.1.9] - 2012-12-27
|
||||
### Fixed
|
||||
- Fixed option dest interferens with other options (issue #23), thanks to @hpaulj
|
||||
- Fixed default value behavior with `*` positionals, thanks to @hpaulj
|
||||
- Improve `getDefault()` behavior, thanks to @hpaulj
|
||||
- Imrove negative argument parsing, thanks to @hpaulj
|
||||
- Improve negative argument parsing, thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.8 / 2012-12-01
|
||||
------------------
|
||||
|
||||
## [0.1.8] - 2012-12-01
|
||||
### Fixed
|
||||
- Fixed parser parents (issue #19), thanks to @hpaulj
|
||||
- Fixed negative argument parse (issue #20), thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.7 / 2012-10-14
|
||||
------------------
|
||||
|
||||
## [0.1.7] - 2012-10-14
|
||||
### Fixed
|
||||
- Fixed 'choices' argument parse (issue #16)
|
||||
- Fixed stderr output (issue #15)
|
||||
|
||||
|
||||
0.1.6 / 2012-09-09
|
||||
------------------
|
||||
|
||||
## [0.1.6] - 2012-09-09
|
||||
### Fixed
|
||||
- Fixed check for conflict of options (thanks to @tomxtobin)
|
||||
|
||||
|
||||
0.1.5 / 2012-09-03
|
||||
------------------
|
||||
|
||||
## [0.1.5] - 2012-09-03
|
||||
### Fixed
|
||||
- Fix parser #setDefaults method (thanks to @tomxtobin)
|
||||
|
||||
|
||||
0.1.4 / 2012-07-30
|
||||
------------------
|
||||
|
||||
## [0.1.4] - 2012-07-30
|
||||
### Fixed
|
||||
- Fixed pseudo-argument support (thanks to @CGamesPlay)
|
||||
- Fixed addHelp default (should be true), if not set (thanks to @benblank)
|
||||
|
||||
|
||||
0.1.3 / 2012-06-27
|
||||
------------------
|
||||
|
||||
## [0.1.3] - 2012-06-27
|
||||
### Fixed
|
||||
- Fixed formatter api name: Formatter -> HelpFormatter
|
||||
|
||||
|
||||
0.1.2 / 2012-05-29
|
||||
------------------
|
||||
|
||||
- Added basic tests
|
||||
## [0.1.2] - 2012-05-29
|
||||
### Fixed
|
||||
- Removed excess whitespace in help
|
||||
- Fixed error reporting, when parcer with subcommands
|
||||
called with empty arguments
|
||||
|
||||
### Added
|
||||
- Added basic tests
|
||||
|
||||
0.1.1 / 2012-05-23
|
||||
------------------
|
||||
|
||||
## [0.1.1] - 2012-05-23
|
||||
### Fixed
|
||||
- Fixed line wrapping in help formatter
|
||||
- Added better error reporting on invalid arguments
|
||||
|
||||
|
||||
0.1.0 / 2012-05-16
|
||||
------------------
|
||||
|
||||
## [0.1.0] - 2012-05-16
|
||||
### Added
|
||||
- First release.
|
||||
|
||||
|
||||
[2.0.1]: https://github.com/nodeca/argparse/compare/2.0.0...2.0.1
|
||||
[2.0.0]: https://github.com/nodeca/argparse/compare/1.0.10...2.0.0
|
||||
[1.0.10]: https://github.com/nodeca/argparse/compare/1.0.9...1.0.10
|
||||
[1.0.9]: https://github.com/nodeca/argparse/compare/1.0.8...1.0.9
|
||||
[1.0.8]: https://github.com/nodeca/argparse/compare/1.0.7...1.0.8
|
||||
[1.0.7]: https://github.com/nodeca/argparse/compare/1.0.6...1.0.7
|
||||
[1.0.6]: https://github.com/nodeca/argparse/compare/1.0.5...1.0.6
|
||||
[1.0.5]: https://github.com/nodeca/argparse/compare/1.0.4...1.0.5
|
||||
[1.0.4]: https://github.com/nodeca/argparse/compare/1.0.3...1.0.4
|
||||
[1.0.3]: https://github.com/nodeca/argparse/compare/1.0.2...1.0.3
|
||||
[1.0.2]: https://github.com/nodeca/argparse/compare/1.0.1...1.0.2
|
||||
[1.0.1]: https://github.com/nodeca/argparse/compare/1.0.0...1.0.1
|
||||
[1.0.0]: https://github.com/nodeca/argparse/compare/0.1.16...1.0.0
|
||||
[0.1.16]: https://github.com/nodeca/argparse/compare/0.1.15...0.1.16
|
||||
[0.1.15]: https://github.com/nodeca/argparse/compare/0.1.14...0.1.15
|
||||
[0.1.14]: https://github.com/nodeca/argparse/compare/0.1.13...0.1.14
|
||||
[0.1.13]: https://github.com/nodeca/argparse/compare/0.1.12...0.1.13
|
||||
[0.1.12]: https://github.com/nodeca/argparse/compare/0.1.11...0.1.12
|
||||
[0.1.11]: https://github.com/nodeca/argparse/compare/0.1.10...0.1.11
|
||||
[0.1.10]: https://github.com/nodeca/argparse/compare/0.1.9...0.1.10
|
||||
[0.1.9]: https://github.com/nodeca/argparse/compare/0.1.8...0.1.9
|
||||
[0.1.8]: https://github.com/nodeca/argparse/compare/0.1.7...0.1.8
|
||||
[0.1.7]: https://github.com/nodeca/argparse/compare/0.1.6...0.1.7
|
||||
[0.1.6]: https://github.com/nodeca/argparse/compare/0.1.5...0.1.6
|
||||
[0.1.5]: https://github.com/nodeca/argparse/compare/0.1.4...0.1.5
|
||||
[0.1.4]: https://github.com/nodeca/argparse/compare/0.1.3...0.1.4
|
||||
[0.1.3]: https://github.com/nodeca/argparse/compare/0.1.2...0.1.3
|
||||
[0.1.2]: https://github.com/nodeca/argparse/compare/0.1.1...0.1.2
|
||||
[0.1.1]: https://github.com/nodeca/argparse/compare/0.1.0...0.1.1
|
||||
[0.1.0]: https://github.com/nodeca/argparse/releases/tag/0.1.0
|
||||
|
|
|
@ -1,21 +1,254 @@
|
|||
(The MIT License)
|
||||
A. HISTORY OF THE SOFTWARE
|
||||
==========================
|
||||
|
||||
Copyright (C) 2012 by Vitaly Puzrin
|
||||
Python was created in the early 1990s by Guido van Rossum at Stichting
|
||||
Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
|
||||
as a successor of a language called ABC. Guido remains Python's
|
||||
principal author, although it includes many contributions from others.
|
||||
|
||||
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:
|
||||
In 1995, Guido continued his work on Python at the Corporation for
|
||||
National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)
|
||||
in Reston, Virginia where he released several versions of the
|
||||
software.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
In May 2000, Guido and the Python core development team moved to
|
||||
BeOpen.com to form the BeOpen PythonLabs team. In October of the same
|
||||
year, the PythonLabs team moved to Digital Creations, which became
|
||||
Zope Corporation. In 2001, the Python Software Foundation (PSF, see
|
||||
https://www.python.org/psf/) was formed, a non-profit organization
|
||||
created specifically to own Python-related Intellectual Property.
|
||||
Zope Corporation was a sponsoring member of the PSF.
|
||||
|
||||
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.
|
||||
All Python releases are Open Source (see http://www.opensource.org for
|
||||
the Open Source Definition). Historically, most, but not all, Python
|
||||
releases have also been GPL-compatible; the table below summarizes
|
||||
the various releases.
|
||||
|
||||
Release Derived Year Owner GPL-
|
||||
from compatible? (1)
|
||||
|
||||
0.9.0 thru 1.2 1991-1995 CWI yes
|
||||
1.3 thru 1.5.2 1.2 1995-1999 CNRI yes
|
||||
1.6 1.5.2 2000 CNRI no
|
||||
2.0 1.6 2000 BeOpen.com no
|
||||
1.6.1 1.6 2001 CNRI yes (2)
|
||||
2.1 2.0+1.6.1 2001 PSF no
|
||||
2.0.1 2.0+1.6.1 2001 PSF yes
|
||||
2.1.1 2.1+2.0.1 2001 PSF yes
|
||||
2.1.2 2.1.1 2002 PSF yes
|
||||
2.1.3 2.1.2 2002 PSF yes
|
||||
2.2 and above 2.1.1 2001-now PSF yes
|
||||
|
||||
Footnotes:
|
||||
|
||||
(1) GPL-compatible doesn't mean that we're distributing Python under
|
||||
the GPL. All Python licenses, unlike the GPL, let you distribute
|
||||
a modified version without making your changes open source. The
|
||||
GPL-compatible licenses make it possible to combine Python with
|
||||
other software that is released under the GPL; the others don't.
|
||||
|
||||
(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
|
||||
because its license has a choice of law clause. According to
|
||||
CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
|
||||
is "not incompatible" with the GPL.
|
||||
|
||||
Thanks to the many outside volunteers who have worked under Guido's
|
||||
direction to make these releases possible.
|
||||
|
||||
|
||||
B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
|
||||
===============================================================
|
||||
|
||||
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
||||
--------------------------------------------
|
||||
|
||||
1. This LICENSE AGREEMENT is between the Python Software Foundation
|
||||
("PSF"), and the Individual or Organization ("Licensee") accessing and
|
||||
otherwise using this software ("Python") in source or binary form and
|
||||
its associated documentation.
|
||||
|
||||
2. Subject to the terms and conditions of this License Agreement, PSF hereby
|
||||
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
|
||||
analyze, test, perform and/or display publicly, prepare derivative works,
|
||||
distribute, and otherwise use Python alone or in any derivative version,
|
||||
provided, however, that PSF's License Agreement and PSF's notice of copyright,
|
||||
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation;
|
||||
All Rights Reserved" are retained in Python alone or in any derivative version
|
||||
prepared by Licensee.
|
||||
|
||||
3. In the event Licensee prepares a derivative work that is based on
|
||||
or incorporates Python or any part thereof, and wants to make
|
||||
the derivative work available to others as provided herein, then
|
||||
Licensee hereby agrees to include in any such work a brief summary of
|
||||
the changes made to Python.
|
||||
|
||||
4. PSF is making Python available to Licensee on an "AS IS"
|
||||
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
||||
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
|
||||
INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
|
||||
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
||||
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
||||
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
|
||||
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
|
||||
6. This License Agreement will automatically terminate upon a material
|
||||
breach of its terms and conditions.
|
||||
|
||||
7. Nothing in this License Agreement shall be deemed to create any
|
||||
relationship of agency, partnership, or joint venture between PSF and
|
||||
Licensee. This License Agreement does not grant permission to use PSF
|
||||
trademarks or trade name in a trademark sense to endorse or promote
|
||||
products or services of Licensee, or any third party.
|
||||
|
||||
8. By copying, installing or otherwise using Python, Licensee
|
||||
agrees to be bound by the terms and conditions of this License
|
||||
Agreement.
|
||||
|
||||
|
||||
BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
|
||||
-------------------------------------------
|
||||
|
||||
BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
|
||||
|
||||
1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
|
||||
office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
|
||||
Individual or Organization ("Licensee") accessing and otherwise using
|
||||
this software in source or binary form and its associated
|
||||
documentation ("the Software").
|
||||
|
||||
2. Subject to the terms and conditions of this BeOpen Python License
|
||||
Agreement, BeOpen hereby grants Licensee a non-exclusive,
|
||||
royalty-free, world-wide license to reproduce, analyze, test, perform
|
||||
and/or display publicly, prepare derivative works, distribute, and
|
||||
otherwise use the Software alone or in any derivative version,
|
||||
provided, however, that the BeOpen Python License is retained in the
|
||||
Software, alone or in any derivative version prepared by Licensee.
|
||||
|
||||
3. BeOpen is making the Software available to Licensee on an "AS IS"
|
||||
basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
|
||||
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
|
||||
INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
|
||||
4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
|
||||
SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
|
||||
AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
|
||||
DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
|
||||
5. This License Agreement will automatically terminate upon a material
|
||||
breach of its terms and conditions.
|
||||
|
||||
6. This License Agreement shall be governed by and interpreted in all
|
||||
respects by the law of the State of California, excluding conflict of
|
||||
law provisions. Nothing in this License Agreement shall be deemed to
|
||||
create any relationship of agency, partnership, or joint venture
|
||||
between BeOpen and Licensee. This License Agreement does not grant
|
||||
permission to use BeOpen trademarks or trade names in a trademark
|
||||
sense to endorse or promote products or services of Licensee, or any
|
||||
third party. As an exception, the "BeOpen Python" logos available at
|
||||
http://www.pythonlabs.com/logos.html may be used according to the
|
||||
permissions granted on that web page.
|
||||
|
||||
7. By copying, installing or otherwise using the software, Licensee
|
||||
agrees to be bound by the terms and conditions of this License
|
||||
Agreement.
|
||||
|
||||
|
||||
CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
|
||||
---------------------------------------
|
||||
|
||||
1. This LICENSE AGREEMENT is between the Corporation for National
|
||||
Research Initiatives, having an office at 1895 Preston White Drive,
|
||||
Reston, VA 20191 ("CNRI"), and the Individual or Organization
|
||||
("Licensee") accessing and otherwise using Python 1.6.1 software in
|
||||
source or binary form and its associated documentation.
|
||||
|
||||
2. Subject to the terms and conditions of this License Agreement, CNRI
|
||||
hereby grants Licensee a nonexclusive, royalty-free, world-wide
|
||||
license to reproduce, analyze, test, perform and/or display publicly,
|
||||
prepare derivative works, distribute, and otherwise use Python 1.6.1
|
||||
alone or in any derivative version, provided, however, that CNRI's
|
||||
License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
|
||||
1995-2001 Corporation for National Research Initiatives; All Rights
|
||||
Reserved" are retained in Python 1.6.1 alone or in any derivative
|
||||
version prepared by Licensee. Alternately, in lieu of CNRI's License
|
||||
Agreement, Licensee may substitute the following text (omitting the
|
||||
quotes): "Python 1.6.1 is made available subject to the terms and
|
||||
conditions in CNRI's License Agreement. This Agreement together with
|
||||
Python 1.6.1 may be located on the Internet using the following
|
||||
unique, persistent identifier (known as a handle): 1895.22/1013. This
|
||||
Agreement may also be obtained from a proxy server on the Internet
|
||||
using the following URL: http://hdl.handle.net/1895.22/1013".
|
||||
|
||||
3. In the event Licensee prepares a derivative work that is based on
|
||||
or incorporates Python 1.6.1 or any part thereof, and wants to make
|
||||
the derivative work available to others as provided herein, then
|
||||
Licensee hereby agrees to include in any such work a brief summary of
|
||||
the changes made to Python 1.6.1.
|
||||
|
||||
4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
|
||||
basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
|
||||
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
|
||||
INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
|
||||
5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
||||
1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
||||
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
|
||||
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
|
||||
6. This License Agreement will automatically terminate upon a material
|
||||
breach of its terms and conditions.
|
||||
|
||||
7. This License Agreement shall be governed by the federal
|
||||
intellectual property law of the United States, including without
|
||||
limitation the federal copyright law, and, to the extent such
|
||||
U.S. federal law does not apply, by the law of the Commonwealth of
|
||||
Virginia, excluding Virginia's conflict of law provisions.
|
||||
Notwithstanding the foregoing, with regard to derivative works based
|
||||
on Python 1.6.1 that incorporate non-separable material that was
|
||||
previously distributed under the GNU General Public License (GPL), the
|
||||
law of the Commonwealth of Virginia shall govern this License
|
||||
Agreement only as to issues arising under or with respect to
|
||||
Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
|
||||
License Agreement shall be deemed to create any relationship of
|
||||
agency, partnership, or joint venture between CNRI and Licensee. This
|
||||
License Agreement does not grant permission to use CNRI trademarks or
|
||||
trade name in a trademark sense to endorse or promote products or
|
||||
services of Licensee, or any third party.
|
||||
|
||||
8. By clicking on the "ACCEPT" button where indicated, or by copying,
|
||||
installing or otherwise using Python 1.6.1, Licensee agrees to be
|
||||
bound by the terms and conditions of this License Agreement.
|
||||
|
||||
ACCEPT
|
||||
|
||||
|
||||
CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
|
||||
--------------------------------------------------
|
||||
|
||||
Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
|
||||
The Netherlands. All rights reserved.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the name of Stichting Mathematisch
|
||||
Centrum or CWI not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior
|
||||
permission.
|
||||
|
||||
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
|
||||
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
|
|
@ -4,69 +4,54 @@ argparse
|
|||
[![Build Status](https://secure.travis-ci.org/nodeca/argparse.svg?branch=master)](http://travis-ci.org/nodeca/argparse)
|
||||
[![NPM version](https://img.shields.io/npm/v/argparse.svg)](https://www.npmjs.org/package/argparse)
|
||||
|
||||
CLI arguments parser for node.js. Javascript port of python's
|
||||
[argparse](http://docs.python.org/dev/library/argparse.html) module
|
||||
(original version 3.2). That's a full port, except some very rare options,
|
||||
recorded in issue tracker.
|
||||
CLI arguments parser for node.js, with [sub-commands](https://docs.python.org/3.9/library/argparse.html#sub-commands) support. Port of python's [argparse](http://docs.python.org/dev/library/argparse.html) (version [3.9.0](https://github.com/python/cpython/blob/v3.9.0rc1/Lib/argparse.py)).
|
||||
|
||||
**NB. Difference with original.**
|
||||
**Difference with original.**
|
||||
|
||||
- Method names changed to camelCase. See [generated docs](http://nodeca.github.com/argparse/).
|
||||
- Use `defaultValue` instead of `default`.
|
||||
- Use `argparse.Const.REMAINDER` instead of `argparse.REMAINDER`, and
|
||||
similarly for constant values `OPTIONAL`, `ZERO_OR_MORE`, and `ONE_OR_MORE`
|
||||
(aliases for `nargs` values `'?'`, `'*'`, `'+'`, respectively), and
|
||||
`SUPPRESS`.
|
||||
- JS has no keyword arguments support.
|
||||
- Pass options instead: `new ArgumentParser({ description: 'example', add_help: true })`.
|
||||
- JS has no python's types `int`, `float`, ...
|
||||
- Use string-typed names: `.add_argument('-b', { type: 'int', help: 'help' })`.
|
||||
- `%r` format specifier uses `require('util').inspect()`.
|
||||
|
||||
More details in [doc](./doc).
|
||||
|
||||
|
||||
Example
|
||||
=======
|
||||
-------
|
||||
|
||||
test.js file:
|
||||
`test.js` file:
|
||||
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({
|
||||
version: '0.0.1',
|
||||
addHelp:true,
|
||||
const { ArgumentParser } = require('argparse');
|
||||
const { version } = require('./package.json');
|
||||
|
||||
const parser = new ArgumentParser({
|
||||
description: 'Argparse example'
|
||||
});
|
||||
parser.addArgument(
|
||||
[ '-f', '--foo' ],
|
||||
{
|
||||
help: 'foo bar'
|
||||
}
|
||||
);
|
||||
parser.addArgument(
|
||||
[ '-b', '--bar' ],
|
||||
{
|
||||
help: 'bar foo'
|
||||
}
|
||||
);
|
||||
parser.addArgument(
|
||||
'--baz',
|
||||
{
|
||||
help: 'baz bar'
|
||||
}
|
||||
);
|
||||
var args = parser.parseArgs();
|
||||
console.dir(args);
|
||||
|
||||
parser.add_argument('-v', '--version', { action: 'version', version });
|
||||
parser.add_argument('-f', '--foo', { help: 'foo bar' });
|
||||
parser.add_argument('-b', '--bar', { help: 'bar foo' });
|
||||
parser.add_argument('--baz', { help: 'baz bar' });
|
||||
|
||||
console.dir(parser.parse_args());
|
||||
```
|
||||
|
||||
Display help:
|
||||
|
||||
```
|
||||
$ ./test.js -h
|
||||
usage: example.js [-h] [-v] [-f FOO] [-b BAR] [--baz BAZ]
|
||||
usage: test.js [-h] [-v] [-f FOO] [-b BAR] [--baz BAZ]
|
||||
|
||||
Argparse example
|
||||
|
||||
Optional arguments:
|
||||
-h, --help Show this help message and exit.
|
||||
-v, --version Show program's version number and exit.
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-v, --version show program's version number and exit
|
||||
-f FOO, --foo FOO foo bar
|
||||
-b BAR, --bar BAR bar foo
|
||||
--baz BAZ baz bar
|
||||
|
@ -79,179 +64,21 @@ $ ./test.js -f=3 --bar=4 --baz 5
|
|||
{ foo: '3', bar: '4', baz: '5' }
|
||||
```
|
||||
|
||||
More [examples](https://github.com/nodeca/argparse/tree/master/examples).
|
||||
|
||||
API docs
|
||||
--------
|
||||
|
||||
Since this is a port with minimal divergence, there's no separate documentation.
|
||||
Use original one instead, with notes about difference.
|
||||
|
||||
1. [Original doc](https://docs.python.org/3.9/library/argparse.html).
|
||||
2. [Original tutorial](https://docs.python.org/3.9/howto/argparse.html).
|
||||
3. [Difference with python](./doc).
|
||||
|
||||
|
||||
ArgumentParser objects
|
||||
======================
|
||||
|
||||
```
|
||||
new ArgumentParser({parameters hash});
|
||||
```
|
||||
|
||||
Creates a new ArgumentParser object.
|
||||
|
||||
**Supported params:**
|
||||
|
||||
- ```description``` - Text to display before the argument help.
|
||||
- ```epilog``` - Text to display after the argument help.
|
||||
- ```addHelp``` - Add a -h/–help option to the parser. (default: true)
|
||||
- ```argumentDefault``` - Set the global default value for arguments. (default: null)
|
||||
- ```parents``` - A list of ArgumentParser objects whose arguments should also be included.
|
||||
- ```prefixChars``` - The set of characters that prefix optional arguments. (default: ‘-‘)
|
||||
- ```formatterClass``` - A class for customizing the help output.
|
||||
- ```prog``` - The name of the program (default: `path.basename(process.argv[1])`)
|
||||
- ```usage``` - The string describing the program usage (default: generated)
|
||||
- ```conflictHandler``` - Usually unnecessary, defines strategy for resolving conflicting optionals.
|
||||
|
||||
**Not supported yet**
|
||||
|
||||
- ```fromfilePrefixChars``` - The set of characters that prefix files from which additional arguments should be read.
|
||||
|
||||
|
||||
Details in [original ArgumentParser guide](http://docs.python.org/dev/library/argparse.html#argumentparser-objects)
|
||||
|
||||
|
||||
addArgument() method
|
||||
====================
|
||||
|
||||
```
|
||||
ArgumentParser.addArgument(name or flag or [name] or [flags...], {options})
|
||||
```
|
||||
|
||||
Defines how a single command-line argument should be parsed.
|
||||
|
||||
- ```name or flag or [name] or [flags...]``` - Either a positional name
|
||||
(e.g., `'foo'`), a single option (e.g., `'-f'` or `'--foo'`), an array
|
||||
of a single positional name (e.g., `['foo']`), or an array of options
|
||||
(e.g., `['-f', '--foo']`).
|
||||
|
||||
Options:
|
||||
|
||||
- ```action``` - The basic type of action to be taken when this argument is encountered at the command line.
|
||||
- ```nargs```- The number of command-line arguments that should be consumed.
|
||||
- ```constant``` - A constant value required by some action and nargs selections.
|
||||
- ```defaultValue``` - The value produced if the argument is absent from the command line.
|
||||
- ```type``` - The type to which the command-line argument should be converted.
|
||||
- ```choices``` - A container of the allowable values for the argument.
|
||||
- ```required``` - Whether or not the command-line option may be omitted (optionals only).
|
||||
- ```help``` - A brief description of what the argument does.
|
||||
- ```metavar``` - A name for the argument in usage messages.
|
||||
- ```dest``` - The name of the attribute to be added to the object returned by parseArgs().
|
||||
|
||||
Details in [original add_argument guide](http://docs.python.org/dev/library/argparse.html#the-add-argument-method)
|
||||
|
||||
|
||||
Action (some details)
|
||||
================
|
||||
|
||||
ArgumentParser objects associate command-line arguments with actions.
|
||||
These actions can do just about anything with the command-line arguments associated
|
||||
with them, though most actions simply add an attribute to the object returned by
|
||||
parseArgs(). The action keyword argument specifies how the command-line arguments
|
||||
should be handled. The supported actions are:
|
||||
|
||||
- ```store``` - Just stores the argument’s value. This is the default action.
|
||||
- ```storeConst``` - Stores value, specified by the const keyword argument.
|
||||
(Note that the const keyword argument defaults to the rather unhelpful None.)
|
||||
The 'storeConst' action is most commonly used with optional arguments, that
|
||||
specify some sort of flag.
|
||||
- ```storeTrue``` and ```storeFalse``` - Stores values True and False
|
||||
respectively. These are special cases of 'storeConst'.
|
||||
- ```append``` - Stores a list, and appends each argument value to the list.
|
||||
This is useful to allow an option to be specified multiple times.
|
||||
- ```appendConst``` - Stores a list, and appends value, specified by the
|
||||
const keyword argument to the list. (Note, that the const keyword argument defaults
|
||||
is None.) The 'appendConst' action is typically used when multiple arguments need
|
||||
to store constants to the same list.
|
||||
- ```count``` - Counts the number of times a keyword argument occurs. For example,
|
||||
used for increasing verbosity levels.
|
||||
- ```help``` - Prints a complete help message for all the options in the current
|
||||
parser and then exits. By default a help action is automatically added to the parser.
|
||||
See ArgumentParser for details of how the output is created.
|
||||
- ```version``` - Prints version information and exit. Expects a `version=`
|
||||
keyword argument in the addArgument() call.
|
||||
|
||||
Details in [original action guide](http://docs.python.org/dev/library/argparse.html#action)
|
||||
|
||||
|
||||
Sub-commands
|
||||
============
|
||||
|
||||
ArgumentParser.addSubparsers()
|
||||
|
||||
Many programs split their functionality into a number of sub-commands, for
|
||||
example, the svn program can invoke sub-commands like `svn checkout`, `svn update`,
|
||||
and `svn commit`. Splitting up functionality this way can be a particularly good
|
||||
idea when a program performs several different functions which require different
|
||||
kinds of command-line arguments. `ArgumentParser` supports creation of such
|
||||
sub-commands with `addSubparsers()` method. The `addSubparsers()` method is
|
||||
normally called with no arguments and returns an special action object.
|
||||
This object has a single method `addParser()`, which takes a command name and
|
||||
any `ArgumentParser` constructor arguments, and returns an `ArgumentParser` object
|
||||
that can be modified as usual.
|
||||
|
||||
Example:
|
||||
|
||||
sub_commands.js
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({
|
||||
version: '0.0.1',
|
||||
addHelp:true,
|
||||
description: 'Argparse examples: sub-commands',
|
||||
});
|
||||
|
||||
var subparsers = parser.addSubparsers({
|
||||
title:'subcommands',
|
||||
dest:"subcommand_name"
|
||||
});
|
||||
|
||||
var bar = subparsers.addParser('c1', {addHelp:true});
|
||||
bar.addArgument(
|
||||
[ '-f', '--foo' ],
|
||||
{
|
||||
action: 'store',
|
||||
help: 'foo3 bar3'
|
||||
}
|
||||
);
|
||||
var bar = subparsers.addParser(
|
||||
'c2',
|
||||
{aliases:['co'], addHelp:true}
|
||||
);
|
||||
bar.addArgument(
|
||||
[ '-b', '--bar' ],
|
||||
{
|
||||
action: 'store',
|
||||
type: 'int',
|
||||
help: 'foo3 bar3'
|
||||
}
|
||||
);
|
||||
|
||||
var args = parser.parseArgs();
|
||||
console.dir(args);
|
||||
|
||||
```
|
||||
|
||||
Details in [original sub-commands guide](http://docs.python.org/dev/library/argparse.html#sub-commands)
|
||||
|
||||
|
||||
Contributors
|
||||
============
|
||||
|
||||
- [Eugene Shkuropat](https://github.com/shkuropat)
|
||||
- [Paul Jacobson](https://github.com/hpaulj)
|
||||
|
||||
[others](https://github.com/nodeca/argparse/graphs/contributors)
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
Copyright (c) 2012 [Vitaly Puzrin](https://github.com/puzrin).
|
||||
Released under the MIT license. See
|
||||
[LICENSE](https://github.com/nodeca/argparse/blob/master/LICENSE) for details.
|
||||
argparse for enterprise
|
||||
-----------------------
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of argparse and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-argparse?utm_source=npm-argparse&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,67 @@
|
|||
// Limited implementation of python % string operator, supports only %s and %r for now
|
||||
// (other formats are not used here, but may appear in custom templates)
|
||||
|
||||
'use strict'
|
||||
|
||||
const { inspect } = require('util')
|
||||
|
||||
|
||||
module.exports = function sub(pattern, ...values) {
|
||||
let regex = /%(?:(%)|(-)?(\*)?(?:\((\w+)\))?([A-Za-z]))/g
|
||||
|
||||
let result = pattern.replace(regex, function (_, is_literal, is_left_align, is_padded, name, format) {
|
||||
if (is_literal) return '%'
|
||||
|
||||
let padded_count = 0
|
||||
if (is_padded) {
|
||||
if (values.length === 0) throw new TypeError('not enough arguments for format string')
|
||||
padded_count = values.shift()
|
||||
if (!Number.isInteger(padded_count)) throw new TypeError('* wants int')
|
||||
}
|
||||
|
||||
let str
|
||||
if (name !== undefined) {
|
||||
let dict = values[0]
|
||||
if (typeof dict !== 'object' || dict === null) throw new TypeError('format requires a mapping')
|
||||
if (!(name in dict)) throw new TypeError(`no such key: '${name}'`)
|
||||
str = dict[name]
|
||||
} else {
|
||||
if (values.length === 0) throw new TypeError('not enough arguments for format string')
|
||||
str = values.shift()
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
case 's':
|
||||
str = String(str)
|
||||
break
|
||||
case 'r':
|
||||
str = inspect(str)
|
||||
break
|
||||
case 'd':
|
||||
case 'i':
|
||||
if (typeof str !== 'number') {
|
||||
throw new TypeError(`%${format} format: a number is required, not ${typeof str}`)
|
||||
}
|
||||
str = String(str.toFixed(0))
|
||||
break
|
||||
default:
|
||||
throw new TypeError(`unsupported format character '${format}'`)
|
||||
}
|
||||
|
||||
if (padded_count > 0) {
|
||||
return is_left_align ? str.padEnd(padded_count) : str.padStart(padded_count)
|
||||
} else {
|
||||
return str
|
||||
}
|
||||
})
|
||||
|
||||
if (values.length) {
|
||||
if (values.length === 1 && typeof values[0] === 'object' && values[0] !== null) {
|
||||
// mapping
|
||||
} else {
|
||||
throw new TypeError('not all arguments converted during string formatting')
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
|
@ -0,0 +1,440 @@
|
|||
// Partial port of python's argparse module, version 3.9.0 (only wrap and fill functions):
|
||||
// https://github.com/python/cpython/blob/v3.9.0b4/Lib/textwrap.py
|
||||
|
||||
'use strict'
|
||||
|
||||
/*
|
||||
* Text wrapping and filling.
|
||||
*/
|
||||
|
||||
// Copyright (C) 1999-2001 Gregory P. Ward.
|
||||
// Copyright (C) 2002, 2003 Python Software Foundation.
|
||||
// Copyright (C) 2020 argparse.js authors
|
||||
// Originally written by Greg Ward <gward@python.net>
|
||||
|
||||
// Hardcode the recognized whitespace characters to the US-ASCII
|
||||
// whitespace characters. The main reason for doing this is that
|
||||
// some Unicode spaces (like \u00a0) are non-breaking whitespaces.
|
||||
//
|
||||
// This less funky little regex just split on recognized spaces. E.g.
|
||||
// "Hello there -- you goof-ball, use the -b option!"
|
||||
// splits into
|
||||
// Hello/ /there/ /--/ /you/ /goof-ball,/ /use/ /the/ /-b/ /option!/
|
||||
const wordsep_simple_re = /([\t\n\x0b\x0c\r ]+)/
|
||||
|
||||
class TextWrapper {
|
||||
/*
|
||||
* Object for wrapping/filling text. The public interface consists of
|
||||
* the wrap() and fill() methods; the other methods are just there for
|
||||
* subclasses to override in order to tweak the default behaviour.
|
||||
* If you want to completely replace the main wrapping algorithm,
|
||||
* you'll probably have to override _wrap_chunks().
|
||||
*
|
||||
* Several instance attributes control various aspects of wrapping:
|
||||
* width (default: 70)
|
||||
* the maximum width of wrapped lines (unless break_long_words
|
||||
* is false)
|
||||
* initial_indent (default: "")
|
||||
* string that will be prepended to the first line of wrapped
|
||||
* output. Counts towards the line's width.
|
||||
* subsequent_indent (default: "")
|
||||
* string that will be prepended to all lines save the first
|
||||
* of wrapped output; also counts towards each line's width.
|
||||
* expand_tabs (default: true)
|
||||
* Expand tabs in input text to spaces before further processing.
|
||||
* Each tab will become 0 .. 'tabsize' spaces, depending on its position
|
||||
* in its line. If false, each tab is treated as a single character.
|
||||
* tabsize (default: 8)
|
||||
* Expand tabs in input text to 0 .. 'tabsize' spaces, unless
|
||||
* 'expand_tabs' is false.
|
||||
* replace_whitespace (default: true)
|
||||
* Replace all whitespace characters in the input text by spaces
|
||||
* after tab expansion. Note that if expand_tabs is false and
|
||||
* replace_whitespace is true, every tab will be converted to a
|
||||
* single space!
|
||||
* fix_sentence_endings (default: false)
|
||||
* Ensure that sentence-ending punctuation is always followed
|
||||
* by two spaces. Off by default because the algorithm is
|
||||
* (unavoidably) imperfect.
|
||||
* break_long_words (default: true)
|
||||
* Break words longer than 'width'. If false, those words will not
|
||||
* be broken, and some lines might be longer than 'width'.
|
||||
* break_on_hyphens (default: true)
|
||||
* Allow breaking hyphenated words. If true, wrapping will occur
|
||||
* preferably on whitespaces and right after hyphens part of
|
||||
* compound words.
|
||||
* drop_whitespace (default: true)
|
||||
* Drop leading and trailing whitespace from lines.
|
||||
* max_lines (default: None)
|
||||
* Truncate wrapped lines.
|
||||
* placeholder (default: ' [...]')
|
||||
* Append to the last line of truncated text.
|
||||
*/
|
||||
|
||||
constructor(options = {}) {
|
||||
let {
|
||||
width = 70,
|
||||
initial_indent = '',
|
||||
subsequent_indent = '',
|
||||
expand_tabs = true,
|
||||
replace_whitespace = true,
|
||||
fix_sentence_endings = false,
|
||||
break_long_words = true,
|
||||
drop_whitespace = true,
|
||||
break_on_hyphens = true,
|
||||
tabsize = 8,
|
||||
max_lines = undefined,
|
||||
placeholder=' [...]'
|
||||
} = options
|
||||
|
||||
this.width = width
|
||||
this.initial_indent = initial_indent
|
||||
this.subsequent_indent = subsequent_indent
|
||||
this.expand_tabs = expand_tabs
|
||||
this.replace_whitespace = replace_whitespace
|
||||
this.fix_sentence_endings = fix_sentence_endings
|
||||
this.break_long_words = break_long_words
|
||||
this.drop_whitespace = drop_whitespace
|
||||
this.break_on_hyphens = break_on_hyphens
|
||||
this.tabsize = tabsize
|
||||
this.max_lines = max_lines
|
||||
this.placeholder = placeholder
|
||||
}
|
||||
|
||||
|
||||
// -- Private methods -----------------------------------------------
|
||||
// (possibly useful for subclasses to override)
|
||||
|
||||
_munge_whitespace(text) {
|
||||
/*
|
||||
* _munge_whitespace(text : string) -> string
|
||||
*
|
||||
* Munge whitespace in text: expand tabs and convert all other
|
||||
* whitespace characters to spaces. Eg. " foo\\tbar\\n\\nbaz"
|
||||
* becomes " foo bar baz".
|
||||
*/
|
||||
if (this.expand_tabs) {
|
||||
text = text.replace(/\t/g, ' '.repeat(this.tabsize)) // not strictly correct in js
|
||||
}
|
||||
if (this.replace_whitespace) {
|
||||
text = text.replace(/[\t\n\x0b\x0c\r]/g, ' ')
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
_split(text) {
|
||||
/*
|
||||
* _split(text : string) -> [string]
|
||||
*
|
||||
* Split the text to wrap into indivisible chunks. Chunks are
|
||||
* not quite the same as words; see _wrap_chunks() for full
|
||||
* details. As an example, the text
|
||||
* Look, goof-ball -- use the -b option!
|
||||
* breaks into the following chunks:
|
||||
* 'Look,', ' ', 'goof-', 'ball', ' ', '--', ' ',
|
||||
* 'use', ' ', 'the', ' ', '-b', ' ', 'option!'
|
||||
* if break_on_hyphens is True, or in:
|
||||
* 'Look,', ' ', 'goof-ball', ' ', '--', ' ',
|
||||
* 'use', ' ', 'the', ' ', '-b', ' ', option!'
|
||||
* otherwise.
|
||||
*/
|
||||
let chunks = text.split(wordsep_simple_re)
|
||||
chunks = chunks.filter(Boolean)
|
||||
return chunks
|
||||
}
|
||||
|
||||
_handle_long_word(reversed_chunks, cur_line, cur_len, width) {
|
||||
/*
|
||||
* _handle_long_word(chunks : [string],
|
||||
* cur_line : [string],
|
||||
* cur_len : int, width : int)
|
||||
*
|
||||
* Handle a chunk of text (most likely a word, not whitespace) that
|
||||
* is too long to fit in any line.
|
||||
*/
|
||||
// Figure out when indent is larger than the specified width, and make
|
||||
// sure at least one character is stripped off on every pass
|
||||
let space_left
|
||||
if (width < 1) {
|
||||
space_left = 1
|
||||
} else {
|
||||
space_left = width - cur_len
|
||||
}
|
||||
|
||||
// If we're allowed to break long words, then do so: put as much
|
||||
// of the next chunk onto the current line as will fit.
|
||||
if (this.break_long_words) {
|
||||
cur_line.push(reversed_chunks[reversed_chunks.length - 1].slice(0, space_left))
|
||||
reversed_chunks[reversed_chunks.length - 1] = reversed_chunks[reversed_chunks.length - 1].slice(space_left)
|
||||
|
||||
// Otherwise, we have to preserve the long word intact. Only add
|
||||
// it to the current line if there's nothing already there --
|
||||
// that minimizes how much we violate the width constraint.
|
||||
} else if (!cur_line) {
|
||||
cur_line.push(...reversed_chunks.pop())
|
||||
}
|
||||
|
||||
// If we're not allowed to break long words, and there's already
|
||||
// text on the current line, do nothing. Next time through the
|
||||
// main loop of _wrap_chunks(), we'll wind up here again, but
|
||||
// cur_len will be zero, so the next line will be entirely
|
||||
// devoted to the long word that we can't handle right now.
|
||||
}
|
||||
|
||||
_wrap_chunks(chunks) {
|
||||
/*
|
||||
* _wrap_chunks(chunks : [string]) -> [string]
|
||||
*
|
||||
* Wrap a sequence of text chunks and return a list of lines of
|
||||
* length 'self.width' or less. (If 'break_long_words' is false,
|
||||
* some lines may be longer than this.) Chunks correspond roughly
|
||||
* to words and the whitespace between them: each chunk is
|
||||
* indivisible (modulo 'break_long_words'), but a line break can
|
||||
* come between any two chunks. Chunks should not have internal
|
||||
* whitespace; ie. a chunk is either all whitespace or a "word".
|
||||
* Whitespace chunks will be removed from the beginning and end of
|
||||
* lines, but apart from that whitespace is preserved.
|
||||
*/
|
||||
let lines = []
|
||||
let indent
|
||||
if (this.width <= 0) {
|
||||
throw Error(`invalid width ${this.width} (must be > 0)`)
|
||||
}
|
||||
if (this.max_lines !== undefined) {
|
||||
if (this.max_lines > 1) {
|
||||
indent = this.subsequent_indent
|
||||
} else {
|
||||
indent = this.initial_indent
|
||||
}
|
||||
if (indent.length + this.placeholder.trimStart().length > this.width) {
|
||||
throw Error('placeholder too large for max width')
|
||||
}
|
||||
}
|
||||
|
||||
// Arrange in reverse order so items can be efficiently popped
|
||||
// from a stack of chucks.
|
||||
chunks = chunks.reverse()
|
||||
|
||||
while (chunks.length > 0) {
|
||||
|
||||
// Start the list of chunks that will make up the current line.
|
||||
// cur_len is just the length of all the chunks in cur_line.
|
||||
let cur_line = []
|
||||
let cur_len = 0
|
||||
|
||||
// Figure out which static string will prefix this line.
|
||||
let indent
|
||||
if (lines) {
|
||||
indent = this.subsequent_indent
|
||||
} else {
|
||||
indent = this.initial_indent
|
||||
}
|
||||
|
||||
// Maximum width for this line.
|
||||
let width = this.width - indent.length
|
||||
|
||||
// First chunk on line is whitespace -- drop it, unless this
|
||||
// is the very beginning of the text (ie. no lines started yet).
|
||||
if (this.drop_whitespace && chunks[chunks.length - 1].trim() === '' && lines.length > 0) {
|
||||
chunks.pop()
|
||||
}
|
||||
|
||||
while (chunks.length > 0) {
|
||||
let l = chunks[chunks.length - 1].length
|
||||
|
||||
// Can at least squeeze this chunk onto the current line.
|
||||
if (cur_len + l <= width) {
|
||||
cur_line.push(chunks.pop())
|
||||
cur_len += l
|
||||
|
||||
// Nope, this line is full.
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// The current line is full, and the next chunk is too big to
|
||||
// fit on *any* line (not just this one).
|
||||
if (chunks.length && chunks[chunks.length - 1].length > width) {
|
||||
this._handle_long_word(chunks, cur_line, cur_len, width)
|
||||
cur_len = cur_line.map(l => l.length).reduce((a, b) => a + b, 0)
|
||||
}
|
||||
|
||||
// If the last chunk on this line is all whitespace, drop it.
|
||||
if (this.drop_whitespace && cur_line.length > 0 && cur_line[cur_line.length - 1].trim() === '') {
|
||||
cur_len -= cur_line[cur_line.length - 1].length
|
||||
cur_line.pop()
|
||||
}
|
||||
|
||||
if (cur_line) {
|
||||
if (this.max_lines === undefined ||
|
||||
lines.length + 1 < this.max_lines ||
|
||||
(chunks.length === 0 ||
|
||||
this.drop_whitespace &&
|
||||
chunks.length === 1 &&
|
||||
!chunks[0].trim()) && cur_len <= width) {
|
||||
// Convert current line back to a string and store it in
|
||||
// list of all lines (return value).
|
||||
lines.push(indent + cur_line.join(''))
|
||||
} else {
|
||||
let had_break = false
|
||||
while (cur_line) {
|
||||
if (cur_line[cur_line.length - 1].trim() &&
|
||||
cur_len + this.placeholder.length <= width) {
|
||||
cur_line.push(this.placeholder)
|
||||
lines.push(indent + cur_line.join(''))
|
||||
had_break = true
|
||||
break
|
||||
}
|
||||
cur_len -= cur_line[-1].length
|
||||
cur_line.pop()
|
||||
}
|
||||
if (!had_break) {
|
||||
if (lines) {
|
||||
let prev_line = lines[lines.length - 1].trimEnd()
|
||||
if (prev_line.length + this.placeholder.length <=
|
||||
this.width) {
|
||||
lines[lines.length - 1] = prev_line + this.placeholder
|
||||
break
|
||||
}
|
||||
}
|
||||
lines.push(indent + this.placeholder.lstrip())
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
_split_chunks(text) {
|
||||
text = this._munge_whitespace(text)
|
||||
return this._split(text)
|
||||
}
|
||||
|
||||
// -- Public interface ----------------------------------------------
|
||||
|
||||
wrap(text) {
|
||||
/*
|
||||
* wrap(text : string) -> [string]
|
||||
*
|
||||
* Reformat the single paragraph in 'text' so it fits in lines of
|
||||
* no more than 'self.width' columns, and return a list of wrapped
|
||||
* lines. Tabs in 'text' are expanded with string.expandtabs(),
|
||||
* and all other whitespace characters (including newline) are
|
||||
* converted to space.
|
||||
*/
|
||||
let chunks = this._split_chunks(text)
|
||||
// not implemented in js
|
||||
//if (this.fix_sentence_endings) {
|
||||
// this._fix_sentence_endings(chunks)
|
||||
//}
|
||||
return this._wrap_chunks(chunks)
|
||||
}
|
||||
|
||||
fill(text) {
|
||||
/*
|
||||
* fill(text : string) -> string
|
||||
*
|
||||
* Reformat the single paragraph in 'text' to fit in lines of no
|
||||
* more than 'self.width' columns, and return a new string
|
||||
* containing the entire wrapped paragraph.
|
||||
*/
|
||||
return this.wrap(text).join('\n')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- Convenience interface ---------------------------------------------
|
||||
|
||||
function wrap(text, options = {}) {
|
||||
/*
|
||||
* Wrap a single paragraph of text, returning a list of wrapped lines.
|
||||
*
|
||||
* Reformat the single paragraph in 'text' so it fits in lines of no
|
||||
* more than 'width' columns, and return a list of wrapped lines. By
|
||||
* default, tabs in 'text' are expanded with string.expandtabs(), and
|
||||
* all other whitespace characters (including newline) are converted to
|
||||
* space. See TextWrapper class for available keyword args to customize
|
||||
* wrapping behaviour.
|
||||
*/
|
||||
let { width = 70, ...kwargs } = options
|
||||
let w = new TextWrapper(Object.assign({ width }, kwargs))
|
||||
return w.wrap(text)
|
||||
}
|
||||
|
||||
function fill(text, options = {}) {
|
||||
/*
|
||||
* Fill a single paragraph of text, returning a new string.
|
||||
*
|
||||
* Reformat the single paragraph in 'text' to fit in lines of no more
|
||||
* than 'width' columns, and return a new string containing the entire
|
||||
* wrapped paragraph. As with wrap(), tabs are expanded and other
|
||||
* whitespace characters converted to space. See TextWrapper class for
|
||||
* available keyword args to customize wrapping behaviour.
|
||||
*/
|
||||
let { width = 70, ...kwargs } = options
|
||||
let w = new TextWrapper(Object.assign({ width }, kwargs))
|
||||
return w.fill(text)
|
||||
}
|
||||
|
||||
// -- Loosely related functionality -------------------------------------
|
||||
|
||||
let _whitespace_only_re = /^[ \t]+$/mg
|
||||
let _leading_whitespace_re = /(^[ \t]*)(?:[^ \t\n])/mg
|
||||
|
||||
function dedent(text) {
|
||||
/*
|
||||
* Remove any common leading whitespace from every line in `text`.
|
||||
*
|
||||
* This can be used to make triple-quoted strings line up with the left
|
||||
* edge of the display, while still presenting them in the source code
|
||||
* in indented form.
|
||||
*
|
||||
* Note that tabs and spaces are both treated as whitespace, but they
|
||||
* are not equal: the lines " hello" and "\\thello" are
|
||||
* considered to have no common leading whitespace.
|
||||
*
|
||||
* Entirely blank lines are normalized to a newline character.
|
||||
*/
|
||||
// Look for the longest leading string of spaces and tabs common to
|
||||
// all lines.
|
||||
let margin = undefined
|
||||
text = text.replace(_whitespace_only_re, '')
|
||||
let indents = text.match(_leading_whitespace_re) || []
|
||||
for (let indent of indents) {
|
||||
indent = indent.slice(0, -1)
|
||||
|
||||
if (margin === undefined) {
|
||||
margin = indent
|
||||
|
||||
// Current line more deeply indented than previous winner:
|
||||
// no change (previous winner is still on top).
|
||||
} else if (indent.startsWith(margin)) {
|
||||
// pass
|
||||
|
||||
// Current line consistent with and no deeper than previous winner:
|
||||
// it's the new winner.
|
||||
} else if (margin.startsWith(indent)) {
|
||||
margin = indent
|
||||
|
||||
// Find the largest common whitespace between current line and previous
|
||||
// winner.
|
||||
} else {
|
||||
for (let i = 0; i < margin.length && i < indent.length; i++) {
|
||||
if (margin[i] !== indent[i]) {
|
||||
margin = margin.slice(0, i)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (margin) {
|
||||
text = text.replace(new RegExp('^' + margin, 'mg'), '')
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
module.exports = { wrap, fill, dedent }
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "argparse",
|
||||
"description": "Very powerful CLI arguments parser. Native port of argparse - python's options parsing library",
|
||||
"version": "1.0.10",
|
||||
"description": "CLI arguments parser. Native port of python's argparse.",
|
||||
"version": "2.0.1",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"parser",
|
||||
|
@ -9,26 +9,23 @@
|
|||
"option",
|
||||
"args"
|
||||
],
|
||||
"contributors": [
|
||||
"Eugene Shkuropat",
|
||||
"Paul Jacobson"
|
||||
],
|
||||
"main": "argparse.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"argparse.js",
|
||||
"lib/"
|
||||
],
|
||||
"license": "MIT",
|
||||
"license": "Python-2.0",
|
||||
"repository": "nodeca/argparse",
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
"lint": "eslint .",
|
||||
"test": "npm run lint && nyc mocha",
|
||||
"coverage": "npm run test && nyc report --reporter html"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^2.13.1",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^3.1.0",
|
||||
"ndoc": "^5.0.1"
|
||||
"@babel/eslint-parser": "^7.11.0",
|
||||
"@babel/plugin-syntax-class-properties": "^7.10.4",
|
||||
"eslint": "^7.5.0",
|
||||
"mocha": "^8.0.1",
|
||||
"nyc": "^15.1.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
../js-yaml/bin/js-yaml.js
|
|
@ -0,0 +1,185 @@
|
|||
1.0.10 / 2018-02-15
|
||||
------------------
|
||||
|
||||
- Use .concat instead of + for arrays, #122.
|
||||
|
||||
|
||||
1.0.9 / 2016-09-29
|
||||
------------------
|
||||
|
||||
- Rerelease after 1.0.8 - deps cleanup.
|
||||
|
||||
|
||||
1.0.8 / 2016-09-29
|
||||
------------------
|
||||
|
||||
- Maintenance (deps bump, fix node 6.5+ tests, coverage report).
|
||||
|
||||
|
||||
1.0.7 / 2016-03-17
|
||||
------------------
|
||||
|
||||
- Teach `addArgument` to accept string arg names. #97, @tomxtobin.
|
||||
|
||||
|
||||
1.0.6 / 2016-02-06
|
||||
------------------
|
||||
|
||||
- Maintenance: moved to eslint & updated CS.
|
||||
|
||||
|
||||
1.0.5 / 2016-02-05
|
||||
------------------
|
||||
|
||||
- Removed lodash dependency to significantly reduce install size.
|
||||
Thanks to @mourner.
|
||||
|
||||
|
||||
1.0.4 / 2016-01-17
|
||||
------------------
|
||||
|
||||
- Maintenance: lodash update to 4.0.0.
|
||||
|
||||
|
||||
1.0.3 / 2015-10-27
|
||||
------------------
|
||||
|
||||
- Fix parse `=` in args: `--examplepath="C:\myfolder\env=x64"`. #84, @CatWithApple.
|
||||
|
||||
|
||||
1.0.2 / 2015-03-22
|
||||
------------------
|
||||
|
||||
- Relaxed lodash version dependency.
|
||||
|
||||
|
||||
1.0.1 / 2015-02-20
|
||||
------------------
|
||||
|
||||
- Changed dependencies to be compatible with ancient nodejs.
|
||||
|
||||
|
||||
1.0.0 / 2015-02-19
|
||||
------------------
|
||||
|
||||
- Maintenance release.
|
||||
- Replaced `underscore` with `lodash`.
|
||||
- Bumped version to 1.0.0 to better reflect semver meaning.
|
||||
- HISTORY.md -> CHANGELOG.md
|
||||
|
||||
|
||||
0.1.16 / 2013-12-01
|
||||
-------------------
|
||||
|
||||
- Maintenance release. Updated dependencies and docs.
|
||||
|
||||
|
||||
0.1.15 / 2013-05-13
|
||||
-------------------
|
||||
|
||||
- Fixed #55, @trebor89
|
||||
|
||||
|
||||
0.1.14 / 2013-05-12
|
||||
-------------------
|
||||
|
||||
- Fixed #62, @maxtaco
|
||||
|
||||
|
||||
0.1.13 / 2013-04-08
|
||||
-------------------
|
||||
|
||||
- Added `.npmignore` to reduce package size
|
||||
|
||||
|
||||
0.1.12 / 2013-02-10
|
||||
-------------------
|
||||
|
||||
- Fixed conflictHandler (#46), @hpaulj
|
||||
|
||||
|
||||
0.1.11 / 2013-02-07
|
||||
-------------------
|
||||
|
||||
- Multiple bugfixes, @hpaulj
|
||||
- Added 70+ tests (ported from python), @hpaulj
|
||||
- Added conflictHandler, @applepicke
|
||||
- Added fromfilePrefixChar, @hpaulj
|
||||
|
||||
|
||||
0.1.10 / 2012-12-30
|
||||
-------------------
|
||||
|
||||
- Added [mutual exclusion](http://docs.python.org/dev/library/argparse.html#mutual-exclusion)
|
||||
support, thanks to @hpaulj
|
||||
- Fixed options check for `storeConst` & `appendConst` actions, thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.9 / 2012-12-27
|
||||
------------------
|
||||
|
||||
- Fixed option dest interferens with other options (issue #23), thanks to @hpaulj
|
||||
- Fixed default value behavior with `*` positionals, thanks to @hpaulj
|
||||
- Improve `getDefault()` behavior, thanks to @hpaulj
|
||||
- Imrove negative argument parsing, thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.8 / 2012-12-01
|
||||
------------------
|
||||
|
||||
- Fixed parser parents (issue #19), thanks to @hpaulj
|
||||
- Fixed negative argument parse (issue #20), thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.7 / 2012-10-14
|
||||
------------------
|
||||
|
||||
- Fixed 'choices' argument parse (issue #16)
|
||||
- Fixed stderr output (issue #15)
|
||||
|
||||
|
||||
0.1.6 / 2012-09-09
|
||||
------------------
|
||||
|
||||
- Fixed check for conflict of options (thanks to @tomxtobin)
|
||||
|
||||
|
||||
0.1.5 / 2012-09-03
|
||||
------------------
|
||||
|
||||
- Fix parser #setDefaults method (thanks to @tomxtobin)
|
||||
|
||||
|
||||
0.1.4 / 2012-07-30
|
||||
------------------
|
||||
|
||||
- Fixed pseudo-argument support (thanks to @CGamesPlay)
|
||||
- Fixed addHelp default (should be true), if not set (thanks to @benblank)
|
||||
|
||||
|
||||
0.1.3 / 2012-06-27
|
||||
------------------
|
||||
|
||||
- Fixed formatter api name: Formatter -> HelpFormatter
|
||||
|
||||
|
||||
0.1.2 / 2012-05-29
|
||||
------------------
|
||||
|
||||
- Added basic tests
|
||||
- Removed excess whitespace in help
|
||||
- Fixed error reporting, when parcer with subcommands
|
||||
called with empty arguments
|
||||
|
||||
|
||||
0.1.1 / 2012-05-23
|
||||
------------------
|
||||
|
||||
- Fixed line wrapping in help formatter
|
||||
- Added better error reporting on invalid arguments
|
||||
|
||||
|
||||
0.1.0 / 2012-05-16
|
||||
------------------
|
||||
|
||||
- First release.
|
|
@ -0,0 +1,21 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (C) 2012 by Vitaly Puzrin
|
||||
|
||||
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.
|
|
@ -0,0 +1,257 @@
|
|||
argparse
|
||||
========
|
||||
|
||||
[![Build Status](https://secure.travis-ci.org/nodeca/argparse.svg?branch=master)](http://travis-ci.org/nodeca/argparse)
|
||||
[![NPM version](https://img.shields.io/npm/v/argparse.svg)](https://www.npmjs.org/package/argparse)
|
||||
|
||||
CLI arguments parser for node.js. Javascript port of python's
|
||||
[argparse](http://docs.python.org/dev/library/argparse.html) module
|
||||
(original version 3.2). That's a full port, except some very rare options,
|
||||
recorded in issue tracker.
|
||||
|
||||
**NB. Difference with original.**
|
||||
|
||||
- Method names changed to camelCase. See [generated docs](http://nodeca.github.com/argparse/).
|
||||
- Use `defaultValue` instead of `default`.
|
||||
- Use `argparse.Const.REMAINDER` instead of `argparse.REMAINDER`, and
|
||||
similarly for constant values `OPTIONAL`, `ZERO_OR_MORE`, and `ONE_OR_MORE`
|
||||
(aliases for `nargs` values `'?'`, `'*'`, `'+'`, respectively), and
|
||||
`SUPPRESS`.
|
||||
|
||||
|
||||
Example
|
||||
=======
|
||||
|
||||
test.js file:
|
||||
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({
|
||||
version: '0.0.1',
|
||||
addHelp:true,
|
||||
description: 'Argparse example'
|
||||
});
|
||||
parser.addArgument(
|
||||
[ '-f', '--foo' ],
|
||||
{
|
||||
help: 'foo bar'
|
||||
}
|
||||
);
|
||||
parser.addArgument(
|
||||
[ '-b', '--bar' ],
|
||||
{
|
||||
help: 'bar foo'
|
||||
}
|
||||
);
|
||||
parser.addArgument(
|
||||
'--baz',
|
||||
{
|
||||
help: 'baz bar'
|
||||
}
|
||||
);
|
||||
var args = parser.parseArgs();
|
||||
console.dir(args);
|
||||
```
|
||||
|
||||
Display help:
|
||||
|
||||
```
|
||||
$ ./test.js -h
|
||||
usage: example.js [-h] [-v] [-f FOO] [-b BAR] [--baz BAZ]
|
||||
|
||||
Argparse example
|
||||
|
||||
Optional arguments:
|
||||
-h, --help Show this help message and exit.
|
||||
-v, --version Show program's version number and exit.
|
||||
-f FOO, --foo FOO foo bar
|
||||
-b BAR, --bar BAR bar foo
|
||||
--baz BAZ baz bar
|
||||
```
|
||||
|
||||
Parse arguments:
|
||||
|
||||
```
|
||||
$ ./test.js -f=3 --bar=4 --baz 5
|
||||
{ foo: '3', bar: '4', baz: '5' }
|
||||
```
|
||||
|
||||
More [examples](https://github.com/nodeca/argparse/tree/master/examples).
|
||||
|
||||
|
||||
ArgumentParser objects
|
||||
======================
|
||||
|
||||
```
|
||||
new ArgumentParser({parameters hash});
|
||||
```
|
||||
|
||||
Creates a new ArgumentParser object.
|
||||
|
||||
**Supported params:**
|
||||
|
||||
- ```description``` - Text to display before the argument help.
|
||||
- ```epilog``` - Text to display after the argument help.
|
||||
- ```addHelp``` - Add a -h/–help option to the parser. (default: true)
|
||||
- ```argumentDefault``` - Set the global default value for arguments. (default: null)
|
||||
- ```parents``` - A list of ArgumentParser objects whose arguments should also be included.
|
||||
- ```prefixChars``` - The set of characters that prefix optional arguments. (default: ‘-‘)
|
||||
- ```formatterClass``` - A class for customizing the help output.
|
||||
- ```prog``` - The name of the program (default: `path.basename(process.argv[1])`)
|
||||
- ```usage``` - The string describing the program usage (default: generated)
|
||||
- ```conflictHandler``` - Usually unnecessary, defines strategy for resolving conflicting optionals.
|
||||
|
||||
**Not supported yet**
|
||||
|
||||
- ```fromfilePrefixChars``` - The set of characters that prefix files from which additional arguments should be read.
|
||||
|
||||
|
||||
Details in [original ArgumentParser guide](http://docs.python.org/dev/library/argparse.html#argumentparser-objects)
|
||||
|
||||
|
||||
addArgument() method
|
||||
====================
|
||||
|
||||
```
|
||||
ArgumentParser.addArgument(name or flag or [name] or [flags...], {options})
|
||||
```
|
||||
|
||||
Defines how a single command-line argument should be parsed.
|
||||
|
||||
- ```name or flag or [name] or [flags...]``` - Either a positional name
|
||||
(e.g., `'foo'`), a single option (e.g., `'-f'` or `'--foo'`), an array
|
||||
of a single positional name (e.g., `['foo']`), or an array of options
|
||||
(e.g., `['-f', '--foo']`).
|
||||
|
||||
Options:
|
||||
|
||||
- ```action``` - The basic type of action to be taken when this argument is encountered at the command line.
|
||||
- ```nargs```- The number of command-line arguments that should be consumed.
|
||||
- ```constant``` - A constant value required by some action and nargs selections.
|
||||
- ```defaultValue``` - The value produced if the argument is absent from the command line.
|
||||
- ```type``` - The type to which the command-line argument should be converted.
|
||||
- ```choices``` - A container of the allowable values for the argument.
|
||||
- ```required``` - Whether or not the command-line option may be omitted (optionals only).
|
||||
- ```help``` - A brief description of what the argument does.
|
||||
- ```metavar``` - A name for the argument in usage messages.
|
||||
- ```dest``` - The name of the attribute to be added to the object returned by parseArgs().
|
||||
|
||||
Details in [original add_argument guide](http://docs.python.org/dev/library/argparse.html#the-add-argument-method)
|
||||
|
||||
|
||||
Action (some details)
|
||||
================
|
||||
|
||||
ArgumentParser objects associate command-line arguments with actions.
|
||||
These actions can do just about anything with the command-line arguments associated
|
||||
with them, though most actions simply add an attribute to the object returned by
|
||||
parseArgs(). The action keyword argument specifies how the command-line arguments
|
||||
should be handled. The supported actions are:
|
||||
|
||||
- ```store``` - Just stores the argument’s value. This is the default action.
|
||||
- ```storeConst``` - Stores value, specified by the const keyword argument.
|
||||
(Note that the const keyword argument defaults to the rather unhelpful None.)
|
||||
The 'storeConst' action is most commonly used with optional arguments, that
|
||||
specify some sort of flag.
|
||||
- ```storeTrue``` and ```storeFalse``` - Stores values True and False
|
||||
respectively. These are special cases of 'storeConst'.
|
||||
- ```append``` - Stores a list, and appends each argument value to the list.
|
||||
This is useful to allow an option to be specified multiple times.
|
||||
- ```appendConst``` - Stores a list, and appends value, specified by the
|
||||
const keyword argument to the list. (Note, that the const keyword argument defaults
|
||||
is None.) The 'appendConst' action is typically used when multiple arguments need
|
||||
to store constants to the same list.
|
||||
- ```count``` - Counts the number of times a keyword argument occurs. For example,
|
||||
used for increasing verbosity levels.
|
||||
- ```help``` - Prints a complete help message for all the options in the current
|
||||
parser and then exits. By default a help action is automatically added to the parser.
|
||||
See ArgumentParser for details of how the output is created.
|
||||
- ```version``` - Prints version information and exit. Expects a `version=`
|
||||
keyword argument in the addArgument() call.
|
||||
|
||||
Details in [original action guide](http://docs.python.org/dev/library/argparse.html#action)
|
||||
|
||||
|
||||
Sub-commands
|
||||
============
|
||||
|
||||
ArgumentParser.addSubparsers()
|
||||
|
||||
Many programs split their functionality into a number of sub-commands, for
|
||||
example, the svn program can invoke sub-commands like `svn checkout`, `svn update`,
|
||||
and `svn commit`. Splitting up functionality this way can be a particularly good
|
||||
idea when a program performs several different functions which require different
|
||||
kinds of command-line arguments. `ArgumentParser` supports creation of such
|
||||
sub-commands with `addSubparsers()` method. The `addSubparsers()` method is
|
||||
normally called with no arguments and returns an special action object.
|
||||
This object has a single method `addParser()`, which takes a command name and
|
||||
any `ArgumentParser` constructor arguments, and returns an `ArgumentParser` object
|
||||
that can be modified as usual.
|
||||
|
||||
Example:
|
||||
|
||||
sub_commands.js
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({
|
||||
version: '0.0.1',
|
||||
addHelp:true,
|
||||
description: 'Argparse examples: sub-commands',
|
||||
});
|
||||
|
||||
var subparsers = parser.addSubparsers({
|
||||
title:'subcommands',
|
||||
dest:"subcommand_name"
|
||||
});
|
||||
|
||||
var bar = subparsers.addParser('c1', {addHelp:true});
|
||||
bar.addArgument(
|
||||
[ '-f', '--foo' ],
|
||||
{
|
||||
action: 'store',
|
||||
help: 'foo3 bar3'
|
||||
}
|
||||
);
|
||||
var bar = subparsers.addParser(
|
||||
'c2',
|
||||
{aliases:['co'], addHelp:true}
|
||||
);
|
||||
bar.addArgument(
|
||||
[ '-b', '--bar' ],
|
||||
{
|
||||
action: 'store',
|
||||
type: 'int',
|
||||
help: 'foo3 bar3'
|
||||
}
|
||||
);
|
||||
|
||||
var args = parser.parseArgs();
|
||||
console.dir(args);
|
||||
|
||||
```
|
||||
|
||||
Details in [original sub-commands guide](http://docs.python.org/dev/library/argparse.html#sub-commands)
|
||||
|
||||
|
||||
Contributors
|
||||
============
|
||||
|
||||
- [Eugene Shkuropat](https://github.com/shkuropat)
|
||||
- [Paul Jacobson](https://github.com/hpaulj)
|
||||
|
||||
[others](https://github.com/nodeca/argparse/graphs/contributors)
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
Copyright (c) 2012 [Vitaly Puzrin](https://github.com/puzrin).
|
||||
Released under the MIT license. See
|
||||
[LICENSE](https://github.com/nodeca/argparse/blob/master/LICENSE) for details.
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = require('./lib/argparse');
|
146
node_modules/eslint/node_modules/argparse/lib/action.js
сгенерированный
поставляемый
Normal file
146
node_modules/eslint/node_modules/argparse/lib/action.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,146 @@
|
|||
/**
|
||||
* class Action
|
||||
*
|
||||
* Base class for all actions
|
||||
* Do not call in your code, use this class only for inherits your own action
|
||||
*
|
||||
* Information about how to convert command line strings to Javascript objects.
|
||||
* Action objects are used by an ArgumentParser to represent the information
|
||||
* needed to parse a single argument from one or more strings from the command
|
||||
* line. The keyword arguments to the Action constructor are also all attributes
|
||||
* of Action instances.
|
||||
*
|
||||
* ##### Allowed keywords:
|
||||
*
|
||||
* - `store`
|
||||
* - `storeConstant`
|
||||
* - `storeTrue`
|
||||
* - `storeFalse`
|
||||
* - `append`
|
||||
* - `appendConstant`
|
||||
* - `count`
|
||||
* - `help`
|
||||
* - `version`
|
||||
*
|
||||
* Information about action options see [[Action.new]]
|
||||
*
|
||||
* See also [original guide](http://docs.python.org/dev/library/argparse.html#action)
|
||||
*
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
// Constants
|
||||
var c = require('./const');
|
||||
|
||||
|
||||
/**
|
||||
* new Action(options)
|
||||
*
|
||||
* Base class for all actions. Used only for inherits
|
||||
*
|
||||
*
|
||||
* ##### Options:
|
||||
*
|
||||
* - `optionStrings` A list of command-line option strings for the action.
|
||||
* - `dest` Attribute to hold the created object(s)
|
||||
* - `nargs` The number of command-line arguments that should be consumed.
|
||||
* By default, one argument will be consumed and a single value will be
|
||||
* produced.
|
||||
* - `constant` Default value for an action with no value.
|
||||
* - `defaultValue` The value to be produced if the option is not specified.
|
||||
* - `type` Cast to 'string'|'int'|'float'|'complex'|function (string). If
|
||||
* None, 'string'.
|
||||
* - `choices` The choices available.
|
||||
* - `required` True if the action must always be specified at the command
|
||||
* line.
|
||||
* - `help` The help describing the argument.
|
||||
* - `metavar` The name to be used for the option's argument with the help
|
||||
* string. If None, the 'dest' value will be used as the name.
|
||||
*
|
||||
* ##### nargs supported values:
|
||||
*
|
||||
* - `N` (an integer) consumes N arguments (and produces a list)
|
||||
* - `?` consumes zero or one arguments
|
||||
* - `*` consumes zero or more arguments (and produces a list)
|
||||
* - `+` consumes one or more arguments (and produces a list)
|
||||
*
|
||||
* Note: that the difference between the default and nargs=1 is that with the
|
||||
* default, a single value will be produced, while with nargs=1, a list
|
||||
* containing a single value will be produced.
|
||||
**/
|
||||
var Action = module.exports = function Action(options) {
|
||||
options = options || {};
|
||||
this.optionStrings = options.optionStrings || [];
|
||||
this.dest = options.dest;
|
||||
this.nargs = typeof options.nargs !== 'undefined' ? options.nargs : null;
|
||||
this.constant = typeof options.constant !== 'undefined' ? options.constant : null;
|
||||
this.defaultValue = options.defaultValue;
|
||||
this.type = typeof options.type !== 'undefined' ? options.type : null;
|
||||
this.choices = typeof options.choices !== 'undefined' ? options.choices : null;
|
||||
this.required = typeof options.required !== 'undefined' ? options.required : false;
|
||||
this.help = typeof options.help !== 'undefined' ? options.help : null;
|
||||
this.metavar = typeof options.metavar !== 'undefined' ? options.metavar : null;
|
||||
|
||||
if (!(this.optionStrings instanceof Array)) {
|
||||
throw new Error('optionStrings should be an array');
|
||||
}
|
||||
if (typeof this.required !== 'undefined' && typeof this.required !== 'boolean') {
|
||||
throw new Error('required should be a boolean');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#getName -> String
|
||||
*
|
||||
* Tells action name
|
||||
**/
|
||||
Action.prototype.getName = function () {
|
||||
if (this.optionStrings.length > 0) {
|
||||
return this.optionStrings.join('/');
|
||||
} else if (this.metavar !== null && this.metavar !== c.SUPPRESS) {
|
||||
return this.metavar;
|
||||
} else if (typeof this.dest !== 'undefined' && this.dest !== c.SUPPRESS) {
|
||||
return this.dest;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#isOptional -> Boolean
|
||||
*
|
||||
* Return true if optional
|
||||
**/
|
||||
Action.prototype.isOptional = function () {
|
||||
return !this.isPositional();
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#isPositional -> Boolean
|
||||
*
|
||||
* Return true if positional
|
||||
**/
|
||||
Action.prototype.isPositional = function () {
|
||||
return (this.optionStrings.length === 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Should be implemented in inherited classes
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* ActionCount.prototype.call = function (parser, namespace, values, optionString) {
|
||||
* namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
|
||||
* };
|
||||
*
|
||||
**/
|
||||
Action.prototype.call = function () {
|
||||
throw new Error('.call() not defined');// Not Implemented error
|
||||
};
|
53
node_modules/eslint/node_modules/argparse/lib/action/append.js
сгенерированный
поставляемый
Normal file
53
node_modules/eslint/node_modules/argparse/lib/action/append.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*:nodoc:*
|
||||
* class ActionAppend
|
||||
*
|
||||
* This action stores a list, and appends each argument value to the list.
|
||||
* This is useful to allow an option to be specified multiple times.
|
||||
* This class inherided from [[Action]]
|
||||
*
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionAppend(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
* Note: options.nargs should be optional for constants
|
||||
* and more then zero for other
|
||||
**/
|
||||
var ActionAppend = module.exports = function ActionAppend(options) {
|
||||
options = options || {};
|
||||
if (this.nargs <= 0) {
|
||||
throw new Error('nargs for append actions must be > 0; if arg ' +
|
||||
'strings are not supplying the value to append, ' +
|
||||
'the append const action may be more appropriate');
|
||||
}
|
||||
if (!!this.constant && this.nargs !== c.OPTIONAL) {
|
||||
throw new Error('nargs must be OPTIONAL to supply const');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionAppend, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionAppend#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionAppend.prototype.call = function (parser, namespace, values) {
|
||||
var items = (namespace[this.dest] || []).slice();
|
||||
items.push(values);
|
||||
namespace.set(this.dest, items);
|
||||
};
|
47
node_modules/eslint/node_modules/argparse/lib/action/append/constant.js
сгенерированный
поставляемый
Normal file
47
node_modules/eslint/node_modules/argparse/lib/action/append/constant.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*:nodoc:*
|
||||
* class ActionAppendConstant
|
||||
*
|
||||
* This stores a list, and appends the value specified by
|
||||
* the const keyword argument to the list.
|
||||
* (Note that the const keyword argument defaults to null.)
|
||||
* The 'appendConst' action is typically useful when multiple
|
||||
* arguments need to store constants to the same list.
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../../action');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionAppendConstant(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionAppendConstant = module.exports = function ActionAppendConstant(options) {
|
||||
options = options || {};
|
||||
options.nargs = 0;
|
||||
if (typeof options.constant === 'undefined') {
|
||||
throw new Error('constant option is required for appendAction');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionAppendConstant, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionAppendConstant#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionAppendConstant.prototype.call = function (parser, namespace) {
|
||||
var items = [].concat(namespace[this.dest] || []);
|
||||
items.push(this.constant);
|
||||
namespace.set(this.dest, items);
|
||||
};
|
40
node_modules/eslint/node_modules/argparse/lib/action/count.js
сгенерированный
поставляемый
Normal file
40
node_modules/eslint/node_modules/argparse/lib/action/count.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*:nodoc:*
|
||||
* class ActionCount
|
||||
*
|
||||
* This counts the number of times a keyword argument occurs.
|
||||
* For example, this is useful for increasing verbosity levels
|
||||
*
|
||||
* This class inherided from [[Action]]
|
||||
*
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionCount(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionCount = module.exports = function ActionCount(options) {
|
||||
options = options || {};
|
||||
options.nargs = 0;
|
||||
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionCount, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionCount#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionCount.prototype.call = function (parser, namespace) {
|
||||
namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
|
||||
};
|
47
node_modules/eslint/node_modules/argparse/lib/action/help.js
сгенерированный
поставляемый
Normal file
47
node_modules/eslint/node_modules/argparse/lib/action/help.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*:nodoc:*
|
||||
* class ActionHelp
|
||||
*
|
||||
* Support action for printing help
|
||||
* This class inherided from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionHelp(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionHelp = module.exports = function ActionHelp(options) {
|
||||
options = options || {};
|
||||
if (options.defaultValue !== null) {
|
||||
options.defaultValue = options.defaultValue;
|
||||
} else {
|
||||
options.defaultValue = c.SUPPRESS;
|
||||
}
|
||||
options.dest = (options.dest !== null ? options.dest : c.SUPPRESS);
|
||||
options.nargs = 0;
|
||||
Action.call(this, options);
|
||||
|
||||
};
|
||||
util.inherits(ActionHelp, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionHelp#call(parser, namespace, values, optionString)
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Print help and exit
|
||||
**/
|
||||
ActionHelp.prototype.call = function (parser) {
|
||||
parser.printHelp();
|
||||
parser.exit();
|
||||
};
|
50
node_modules/eslint/node_modules/argparse/lib/action/store.js
сгенерированный
поставляемый
Normal file
50
node_modules/eslint/node_modules/argparse/lib/action/store.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*:nodoc:*
|
||||
* class ActionStore
|
||||
*
|
||||
* This action just stores the argument’s value. This is the default action.
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
*
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStore(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStore = module.exports = function ActionStore(options) {
|
||||
options = options || {};
|
||||
if (this.nargs <= 0) {
|
||||
throw new Error('nargs for store actions must be > 0; if you ' +
|
||||
'have nothing to store, actions such as store ' +
|
||||
'true or store const may be more appropriate');
|
||||
|
||||
}
|
||||
if (typeof this.constant !== 'undefined' && this.nargs !== c.OPTIONAL) {
|
||||
throw new Error('nargs must be OPTIONAL to supply const');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStore, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionStore#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionStore.prototype.call = function (parser, namespace, values) {
|
||||
namespace.set(this.dest, values);
|
||||
};
|
43
node_modules/eslint/node_modules/argparse/lib/action/store/constant.js
сгенерированный
поставляемый
Normal file
43
node_modules/eslint/node_modules/argparse/lib/action/store/constant.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*:nodoc:*
|
||||
* class ActionStoreConstant
|
||||
*
|
||||
* This action stores the value specified by the const keyword argument.
|
||||
* (Note that the const keyword argument defaults to the rather unhelpful null.)
|
||||
* The 'store_const' action is most commonly used with optional
|
||||
* arguments that specify some sort of flag.
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../../action');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStoreConstant(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStoreConstant = module.exports = function ActionStoreConstant(options) {
|
||||
options = options || {};
|
||||
options.nargs = 0;
|
||||
if (typeof options.constant === 'undefined') {
|
||||
throw new Error('constant option is required for storeAction');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStoreConstant, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionStoreConstant#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionStoreConstant.prototype.call = function (parser, namespace) {
|
||||
namespace.set(this.dest, this.constant);
|
||||
};
|
27
node_modules/eslint/node_modules/argparse/lib/action/store/false.js
сгенерированный
поставляемый
Normal file
27
node_modules/eslint/node_modules/argparse/lib/action/store/false.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*:nodoc:*
|
||||
* class ActionStoreFalse
|
||||
*
|
||||
* This action store the values False respectively.
|
||||
* This is special cases of 'storeConst'
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var ActionStoreConstant = require('./constant');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStoreFalse(options)
|
||||
* - options (object): hash of options see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStoreFalse = module.exports = function ActionStoreFalse(options) {
|
||||
options = options || {};
|
||||
options.constant = false;
|
||||
options.defaultValue = options.defaultValue !== null ? options.defaultValue : true;
|
||||
ActionStoreConstant.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStoreFalse, ActionStoreConstant);
|
26
node_modules/eslint/node_modules/argparse/lib/action/store/true.js
сгенерированный
поставляемый
Normal file
26
node_modules/eslint/node_modules/argparse/lib/action/store/true.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*:nodoc:*
|
||||
* class ActionStoreTrue
|
||||
*
|
||||
* This action store the values True respectively.
|
||||
* This isspecial cases of 'storeConst'
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var ActionStoreConstant = require('./constant');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStoreTrue(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStoreTrue = module.exports = function ActionStoreTrue(options) {
|
||||
options = options || {};
|
||||
options.constant = true;
|
||||
options.defaultValue = options.defaultValue !== null ? options.defaultValue : false;
|
||||
ActionStoreConstant.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStoreTrue, ActionStoreConstant);
|
149
node_modules/eslint/node_modules/argparse/lib/action/subparsers.js
сгенерированный
поставляемый
Normal file
149
node_modules/eslint/node_modules/argparse/lib/action/subparsers.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,149 @@
|
|||
/** internal
|
||||
* class ActionSubparsers
|
||||
*
|
||||
* Support the creation of such sub-commands with the addSubparsers()
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var format = require('util').format;
|
||||
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
// Errors
|
||||
var argumentErrorHelper = require('../argument/error');
|
||||
|
||||
|
||||
/*:nodoc:*
|
||||
* new ChoicesPseudoAction(name, help)
|
||||
*
|
||||
* Create pseudo action for correct help text
|
||||
*
|
||||
**/
|
||||
function ChoicesPseudoAction(name, help) {
|
||||
var options = {
|
||||
optionStrings: [],
|
||||
dest: name,
|
||||
help: help
|
||||
};
|
||||
|
||||
Action.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(ChoicesPseudoAction, Action);
|
||||
|
||||
/**
|
||||
* new ActionSubparsers(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
function ActionSubparsers(options) {
|
||||
options = options || {};
|
||||
options.dest = options.dest || c.SUPPRESS;
|
||||
options.nargs = c.PARSER;
|
||||
|
||||
this.debug = (options.debug === true);
|
||||
|
||||
this._progPrefix = options.prog;
|
||||
this._parserClass = options.parserClass;
|
||||
this._nameParserMap = {};
|
||||
this._choicesActions = [];
|
||||
|
||||
options.choices = this._nameParserMap;
|
||||
Action.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(ActionSubparsers, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionSubparsers#addParser(name, options) -> ArgumentParser
|
||||
* - name (string): sub-command name
|
||||
* - options (object): see [[ArgumentParser.new]]
|
||||
*
|
||||
* Note:
|
||||
* addParser supports an additional aliases option,
|
||||
* which allows multiple strings to refer to the same subparser.
|
||||
* This example, like svn, aliases co as a shorthand for checkout
|
||||
*
|
||||
**/
|
||||
ActionSubparsers.prototype.addParser = function (name, options) {
|
||||
var parser;
|
||||
|
||||
var self = this;
|
||||
|
||||
options = options || {};
|
||||
|
||||
options.debug = (this.debug === true);
|
||||
|
||||
// set program from the existing prefix
|
||||
if (!options.prog) {
|
||||
options.prog = this._progPrefix + ' ' + name;
|
||||
}
|
||||
|
||||
var aliases = options.aliases || [];
|
||||
|
||||
// create a pseudo-action to hold the choice help
|
||||
if (!!options.help || typeof options.help === 'string') {
|
||||
var help = options.help;
|
||||
delete options.help;
|
||||
|
||||
var choiceAction = new ChoicesPseudoAction(name, help);
|
||||
this._choicesActions.push(choiceAction);
|
||||
}
|
||||
|
||||
// create the parser and add it to the map
|
||||
parser = new this._parserClass(options);
|
||||
this._nameParserMap[name] = parser;
|
||||
|
||||
// make parser available under aliases also
|
||||
aliases.forEach(function (alias) {
|
||||
self._nameParserMap[alias] = parser;
|
||||
});
|
||||
|
||||
return parser;
|
||||
};
|
||||
|
||||
ActionSubparsers.prototype._getSubactions = function () {
|
||||
return this._choicesActions;
|
||||
};
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionSubparsers#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Parse input aguments
|
||||
**/
|
||||
ActionSubparsers.prototype.call = function (parser, namespace, values) {
|
||||
var parserName = values[0];
|
||||
var argStrings = values.slice(1);
|
||||
|
||||
// set the parser name if requested
|
||||
if (this.dest !== c.SUPPRESS) {
|
||||
namespace[this.dest] = parserName;
|
||||
}
|
||||
|
||||
// select the parser
|
||||
if (this._nameParserMap[parserName]) {
|
||||
parser = this._nameParserMap[parserName];
|
||||
} else {
|
||||
throw argumentErrorHelper(format(
|
||||
'Unknown parser "%s" (choices: [%s]).',
|
||||
parserName,
|
||||
Object.keys(this._nameParserMap).join(', ')
|
||||
));
|
||||
}
|
||||
|
||||
// parse all the remaining options into the namespace
|
||||
parser.parseArgs(argStrings, namespace);
|
||||
};
|
||||
|
||||
module.exports = ActionSubparsers;
|
47
node_modules/eslint/node_modules/argparse/lib/action/version.js
сгенерированный
поставляемый
Normal file
47
node_modules/eslint/node_modules/argparse/lib/action/version.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*:nodoc:*
|
||||
* class ActionVersion
|
||||
*
|
||||
* Support action for printing program version
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
var c = require('../const');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionVersion(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionVersion = module.exports = function ActionVersion(options) {
|
||||
options = options || {};
|
||||
options.defaultValue = (options.defaultValue ? options.defaultValue : c.SUPPRESS);
|
||||
options.dest = (options.dest || c.SUPPRESS);
|
||||
options.nargs = 0;
|
||||
this.version = options.version;
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionVersion, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionVersion#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Print version and exit
|
||||
**/
|
||||
ActionVersion.prototype.call = function (parser) {
|
||||
var version = this.version || parser.version;
|
||||
var formatter = parser._getFormatter();
|
||||
formatter.addText(version);
|
||||
parser.exit(0, formatter.formatHelp());
|
||||
};
|
482
node_modules/eslint/node_modules/argparse/lib/action_container.js
сгенерированный
поставляемый
Normal file
482
node_modules/eslint/node_modules/argparse/lib/action_container.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,482 @@
|
|||
/** internal
|
||||
* class ActionContainer
|
||||
*
|
||||
* Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]]
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var format = require('util').format;
|
||||
|
||||
// Constants
|
||||
var c = require('./const');
|
||||
|
||||
var $$ = require('./utils');
|
||||
|
||||
//Actions
|
||||
var ActionHelp = require('./action/help');
|
||||
var ActionAppend = require('./action/append');
|
||||
var ActionAppendConstant = require('./action/append/constant');
|
||||
var ActionCount = require('./action/count');
|
||||
var ActionStore = require('./action/store');
|
||||
var ActionStoreConstant = require('./action/store/constant');
|
||||
var ActionStoreTrue = require('./action/store/true');
|
||||
var ActionStoreFalse = require('./action/store/false');
|
||||
var ActionVersion = require('./action/version');
|
||||
var ActionSubparsers = require('./action/subparsers');
|
||||
|
||||
// Errors
|
||||
var argumentErrorHelper = require('./argument/error');
|
||||
|
||||
/**
|
||||
* new ActionContainer(options)
|
||||
*
|
||||
* Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]]
|
||||
*
|
||||
* ##### Options:
|
||||
*
|
||||
* - `description` -- A description of what the program does
|
||||
* - `prefixChars` -- Characters that prefix optional arguments
|
||||
* - `argumentDefault` -- The default value for all arguments
|
||||
* - `conflictHandler` -- The conflict handler to use for duplicate arguments
|
||||
**/
|
||||
var ActionContainer = module.exports = function ActionContainer(options) {
|
||||
options = options || {};
|
||||
|
||||
this.description = options.description;
|
||||
this.argumentDefault = options.argumentDefault;
|
||||
this.prefixChars = options.prefixChars || '';
|
||||
this.conflictHandler = options.conflictHandler;
|
||||
|
||||
// set up registries
|
||||
this._registries = {};
|
||||
|
||||
// register actions
|
||||
this.register('action', null, ActionStore);
|
||||
this.register('action', 'store', ActionStore);
|
||||
this.register('action', 'storeConst', ActionStoreConstant);
|
||||
this.register('action', 'storeTrue', ActionStoreTrue);
|
||||
this.register('action', 'storeFalse', ActionStoreFalse);
|
||||
this.register('action', 'append', ActionAppend);
|
||||
this.register('action', 'appendConst', ActionAppendConstant);
|
||||
this.register('action', 'count', ActionCount);
|
||||
this.register('action', 'help', ActionHelp);
|
||||
this.register('action', 'version', ActionVersion);
|
||||
this.register('action', 'parsers', ActionSubparsers);
|
||||
|
||||
// raise an exception if the conflict handler is invalid
|
||||
this._getHandler();
|
||||
|
||||
// action storage
|
||||
this._actions = [];
|
||||
this._optionStringActions = {};
|
||||
|
||||
// groups
|
||||
this._actionGroups = [];
|
||||
this._mutuallyExclusiveGroups = [];
|
||||
|
||||
// defaults storage
|
||||
this._defaults = {};
|
||||
|
||||
// determines whether an "option" looks like a negative number
|
||||
// -1, -1.5 -5e+4
|
||||
this._regexpNegativeNumber = new RegExp('^[-]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$');
|
||||
|
||||
// whether or not there are any optionals that look like negative
|
||||
// numbers -- uses a list so it can be shared and edited
|
||||
this._hasNegativeNumberOptionals = [];
|
||||
};
|
||||
|
||||
// Groups must be required, then ActionContainer already defined
|
||||
var ArgumentGroup = require('./argument/group');
|
||||
var MutuallyExclusiveGroup = require('./argument/exclusive');
|
||||
|
||||
//
|
||||
// Registration methods
|
||||
//
|
||||
|
||||
/**
|
||||
* ActionContainer#register(registryName, value, object) -> Void
|
||||
* - registryName (String) : object type action|type
|
||||
* - value (string) : keyword
|
||||
* - object (Object|Function) : handler
|
||||
*
|
||||
* Register handlers
|
||||
**/
|
||||
ActionContainer.prototype.register = function (registryName, value, object) {
|
||||
this._registries[registryName] = this._registries[registryName] || {};
|
||||
this._registries[registryName][value] = object;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._registryGet = function (registryName, value, defaultValue) {
|
||||
if (arguments.length < 3) {
|
||||
defaultValue = null;
|
||||
}
|
||||
return this._registries[registryName][value] || defaultValue;
|
||||
};
|
||||
|
||||
//
|
||||
// Namespace default accessor methods
|
||||
//
|
||||
|
||||
/**
|
||||
* ActionContainer#setDefaults(options) -> Void
|
||||
* - options (object):hash of options see [[Action.new]]
|
||||
*
|
||||
* Set defaults
|
||||
**/
|
||||
ActionContainer.prototype.setDefaults = function (options) {
|
||||
options = options || {};
|
||||
for (var property in options) {
|
||||
if ($$.has(options, property)) {
|
||||
this._defaults[property] = options[property];
|
||||
}
|
||||
}
|
||||
|
||||
// if these defaults match any existing arguments, replace the previous
|
||||
// default on the object with the new one
|
||||
this._actions.forEach(function (action) {
|
||||
if ($$.has(options, action.dest)) {
|
||||
action.defaultValue = options[action.dest];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* ActionContainer#getDefault(dest) -> Mixed
|
||||
* - dest (string): action destination
|
||||
*
|
||||
* Return action default value
|
||||
**/
|
||||
ActionContainer.prototype.getDefault = function (dest) {
|
||||
var result = $$.has(this._defaults, dest) ? this._defaults[dest] : null;
|
||||
|
||||
this._actions.forEach(function (action) {
|
||||
if (action.dest === dest && $$.has(action, 'defaultValue')) {
|
||||
result = action.defaultValue;
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
//
|
||||
// Adding argument actions
|
||||
//
|
||||
|
||||
/**
|
||||
* ActionContainer#addArgument(args, options) -> Object
|
||||
* - args (String|Array): argument key, or array of argument keys
|
||||
* - options (Object): action objects see [[Action.new]]
|
||||
*
|
||||
* #### Examples
|
||||
* - addArgument([ '-f', '--foo' ], { action: 'store', defaultValue: 1, ... })
|
||||
* - addArgument([ 'bar' ], { action: 'store', nargs: 1, ... })
|
||||
* - addArgument('--baz', { action: 'store', nargs: 1, ... })
|
||||
**/
|
||||
ActionContainer.prototype.addArgument = function (args, options) {
|
||||
args = args;
|
||||
options = options || {};
|
||||
|
||||
if (typeof args === 'string') {
|
||||
args = [ args ];
|
||||
}
|
||||
if (!Array.isArray(args)) {
|
||||
throw new TypeError('addArgument first argument should be a string or an array');
|
||||
}
|
||||
if (typeof options !== 'object' || Array.isArray(options)) {
|
||||
throw new TypeError('addArgument second argument should be a hash');
|
||||
}
|
||||
|
||||
// if no positional args are supplied or only one is supplied and
|
||||
// it doesn't look like an option string, parse a positional argument
|
||||
if (!args || args.length === 1 && this.prefixChars.indexOf(args[0][0]) < 0) {
|
||||
if (args && !!options.dest) {
|
||||
throw new Error('dest supplied twice for positional argument');
|
||||
}
|
||||
options = this._getPositional(args, options);
|
||||
|
||||
// otherwise, we're adding an optional argument
|
||||
} else {
|
||||
options = this._getOptional(args, options);
|
||||
}
|
||||
|
||||
// if no default was supplied, use the parser-level default
|
||||
if (typeof options.defaultValue === 'undefined') {
|
||||
var dest = options.dest;
|
||||
if ($$.has(this._defaults, dest)) {
|
||||
options.defaultValue = this._defaults[dest];
|
||||
} else if (typeof this.argumentDefault !== 'undefined') {
|
||||
options.defaultValue = this.argumentDefault;
|
||||
}
|
||||
}
|
||||
|
||||
// create the action object, and add it to the parser
|
||||
var ActionClass = this._popActionClass(options);
|
||||
if (typeof ActionClass !== 'function') {
|
||||
throw new Error(format('Unknown action "%s".', ActionClass));
|
||||
}
|
||||
var action = new ActionClass(options);
|
||||
|
||||
// throw an error if the action type is not callable
|
||||
var typeFunction = this._registryGet('type', action.type, action.type);
|
||||
if (typeof typeFunction !== 'function') {
|
||||
throw new Error(format('"%s" is not callable', typeFunction));
|
||||
}
|
||||
|
||||
return this._addAction(action);
|
||||
};
|
||||
|
||||
/**
|
||||
* ActionContainer#addArgumentGroup(options) -> ArgumentGroup
|
||||
* - options (Object): hash of options see [[ArgumentGroup.new]]
|
||||
*
|
||||
* Create new arguments groups
|
||||
**/
|
||||
ActionContainer.prototype.addArgumentGroup = function (options) {
|
||||
var group = new ArgumentGroup(this, options);
|
||||
this._actionGroups.push(group);
|
||||
return group;
|
||||
};
|
||||
|
||||
/**
|
||||
* ActionContainer#addMutuallyExclusiveGroup(options) -> ArgumentGroup
|
||||
* - options (Object): {required: false}
|
||||
*
|
||||
* Create new mutual exclusive groups
|
||||
**/
|
||||
ActionContainer.prototype.addMutuallyExclusiveGroup = function (options) {
|
||||
var group = new MutuallyExclusiveGroup(this, options);
|
||||
this._mutuallyExclusiveGroups.push(group);
|
||||
return group;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._addAction = function (action) {
|
||||
var self = this;
|
||||
|
||||
// resolve any conflicts
|
||||
this._checkConflict(action);
|
||||
|
||||
// add to actions list
|
||||
this._actions.push(action);
|
||||
action.container = this;
|
||||
|
||||
// index the action by any option strings it has
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
self._optionStringActions[optionString] = action;
|
||||
});
|
||||
|
||||
// set the flag if any option strings look like negative numbers
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
if (optionString.match(self._regexpNegativeNumber)) {
|
||||
if (!self._hasNegativeNumberOptionals.some(Boolean)) {
|
||||
self._hasNegativeNumberOptionals.push(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// return the created action
|
||||
return action;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._removeAction = function (action) {
|
||||
var actionIndex = this._actions.indexOf(action);
|
||||
if (actionIndex >= 0) {
|
||||
this._actions.splice(actionIndex, 1);
|
||||
}
|
||||
};
|
||||
|
||||
ActionContainer.prototype._addContainerActions = function (container) {
|
||||
// collect groups by titles
|
||||
var titleGroupMap = {};
|
||||
this._actionGroups.forEach(function (group) {
|
||||
if (titleGroupMap[group.title]) {
|
||||
throw new Error(format('Cannot merge actions - two groups are named "%s".', group.title));
|
||||
}
|
||||
titleGroupMap[group.title] = group;
|
||||
});
|
||||
|
||||
// map each action to its group
|
||||
var groupMap = {};
|
||||
function actionHash(action) {
|
||||
// unique (hopefully?) string suitable as dictionary key
|
||||
return action.getName();
|
||||
}
|
||||
container._actionGroups.forEach(function (group) {
|
||||
// if a group with the title exists, use that, otherwise
|
||||
// create a new group matching the container's group
|
||||
if (!titleGroupMap[group.title]) {
|
||||
titleGroupMap[group.title] = this.addArgumentGroup({
|
||||
title: group.title,
|
||||
description: group.description
|
||||
});
|
||||
}
|
||||
|
||||
// map the actions to their new group
|
||||
group._groupActions.forEach(function (action) {
|
||||
groupMap[actionHash(action)] = titleGroupMap[group.title];
|
||||
});
|
||||
}, this);
|
||||
|
||||
// add container's mutually exclusive groups
|
||||
// NOTE: if add_mutually_exclusive_group ever gains title= and
|
||||
// description= then this code will need to be expanded as above
|
||||
var mutexGroup;
|
||||
container._mutuallyExclusiveGroups.forEach(function (group) {
|
||||
mutexGroup = this.addMutuallyExclusiveGroup({
|
||||
required: group.required
|
||||
});
|
||||
// map the actions to their new mutex group
|
||||
group._groupActions.forEach(function (action) {
|
||||
groupMap[actionHash(action)] = mutexGroup;
|
||||
});
|
||||
}, this); // forEach takes a 'this' argument
|
||||
|
||||
// add all actions to this container or their group
|
||||
container._actions.forEach(function (action) {
|
||||
var key = actionHash(action);
|
||||
if (groupMap[key]) {
|
||||
groupMap[key]._addAction(action);
|
||||
} else {
|
||||
this._addAction(action);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
ActionContainer.prototype._getPositional = function (dest, options) {
|
||||
if (Array.isArray(dest)) {
|
||||
dest = dest[0];
|
||||
}
|
||||
// make sure required is not specified
|
||||
if (options.required) {
|
||||
throw new Error('"required" is an invalid argument for positionals.');
|
||||
}
|
||||
|
||||
// mark positional arguments as required if at least one is
|
||||
// always required
|
||||
if (options.nargs !== c.OPTIONAL && options.nargs !== c.ZERO_OR_MORE) {
|
||||
options.required = true;
|
||||
}
|
||||
if (options.nargs === c.ZERO_OR_MORE && typeof options.defaultValue === 'undefined') {
|
||||
options.required = true;
|
||||
}
|
||||
|
||||
// return the keyword arguments with no option strings
|
||||
options.dest = dest;
|
||||
options.optionStrings = [];
|
||||
return options;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._getOptional = function (args, options) {
|
||||
var prefixChars = this.prefixChars;
|
||||
var optionStrings = [];
|
||||
var optionStringsLong = [];
|
||||
|
||||
// determine short and long option strings
|
||||
args.forEach(function (optionString) {
|
||||
// error on strings that don't start with an appropriate prefix
|
||||
if (prefixChars.indexOf(optionString[0]) < 0) {
|
||||
throw new Error(format('Invalid option string "%s": must start with a "%s".',
|
||||
optionString,
|
||||
prefixChars
|
||||
));
|
||||
}
|
||||
|
||||
// strings starting with two prefix characters are long options
|
||||
optionStrings.push(optionString);
|
||||
if (optionString.length > 1 && prefixChars.indexOf(optionString[1]) >= 0) {
|
||||
optionStringsLong.push(optionString);
|
||||
}
|
||||
});
|
||||
|
||||
// infer dest, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'
|
||||
var dest = options.dest || null;
|
||||
delete options.dest;
|
||||
|
||||
if (!dest) {
|
||||
var optionStringDest = optionStringsLong.length ? optionStringsLong[0] : optionStrings[0];
|
||||
dest = $$.trimChars(optionStringDest, this.prefixChars);
|
||||
|
||||
if (dest.length === 0) {
|
||||
throw new Error(
|
||||
format('dest= is required for options like "%s"', optionStrings.join(', '))
|
||||
);
|
||||
}
|
||||
dest = dest.replace(/-/g, '_');
|
||||
}
|
||||
|
||||
// return the updated keyword arguments
|
||||
options.dest = dest;
|
||||
options.optionStrings = optionStrings;
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._popActionClass = function (options, defaultValue) {
|
||||
defaultValue = defaultValue || null;
|
||||
|
||||
var action = (options.action || defaultValue);
|
||||
delete options.action;
|
||||
|
||||
var actionClass = this._registryGet('action', action, action);
|
||||
return actionClass;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._getHandler = function () {
|
||||
var handlerString = this.conflictHandler;
|
||||
var handlerFuncName = '_handleConflict' + $$.capitalize(handlerString);
|
||||
var func = this[handlerFuncName];
|
||||
if (typeof func === 'undefined') {
|
||||
var msg = 'invalid conflict resolution value: ' + handlerString;
|
||||
throw new Error(msg);
|
||||
} else {
|
||||
return func;
|
||||
}
|
||||
};
|
||||
|
||||
ActionContainer.prototype._checkConflict = function (action) {
|
||||
var optionStringActions = this._optionStringActions;
|
||||
var conflictOptionals = [];
|
||||
|
||||
// find all options that conflict with this option
|
||||
// collect pairs, the string, and an existing action that it conflicts with
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
var conflOptional = optionStringActions[optionString];
|
||||
if (typeof conflOptional !== 'undefined') {
|
||||
conflictOptionals.push([ optionString, conflOptional ]);
|
||||
}
|
||||
});
|
||||
|
||||
if (conflictOptionals.length > 0) {
|
||||
var conflictHandler = this._getHandler();
|
||||
conflictHandler.call(this, action, conflictOptionals);
|
||||
}
|
||||
};
|
||||
|
||||
ActionContainer.prototype._handleConflictError = function (action, conflOptionals) {
|
||||
var conflicts = conflOptionals.map(function (pair) { return pair[0]; });
|
||||
conflicts = conflicts.join(', ');
|
||||
throw argumentErrorHelper(
|
||||
action,
|
||||
format('Conflicting option string(s): %s', conflicts)
|
||||
);
|
||||
};
|
||||
|
||||
ActionContainer.prototype._handleConflictResolve = function (action, conflOptionals) {
|
||||
// remove all conflicting options
|
||||
var self = this;
|
||||
conflOptionals.forEach(function (pair) {
|
||||
var optionString = pair[0];
|
||||
var conflictingAction = pair[1];
|
||||
// remove the conflicting option string
|
||||
var i = conflictingAction.optionStrings.indexOf(optionString);
|
||||
if (i >= 0) {
|
||||
conflictingAction.optionStrings.splice(i, 1);
|
||||
}
|
||||
delete self._optionStringActions[optionString];
|
||||
// if the option now has no option string, remove it from the
|
||||
// container holding it
|
||||
if (conflictingAction.optionStrings.length === 0) {
|
||||
conflictingAction.container._removeAction(conflictingAction);
|
||||
}
|
||||
});
|
||||
};
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче