summaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/node_modules/js-yaml/node_modules/argparse/examples')
-rwxr-xr-xtools/eslint/node_modules/js-yaml/node_modules/argparse/examples/arguments.js36
-rwxr-xr-xtools/eslint/node_modules/js-yaml/node_modules/argparse/examples/choice.js22
-rwxr-xr-xtools/eslint/node_modules/js-yaml/node_modules/argparse/examples/constants.js59
-rwxr-xr-xtools/eslint/node_modules/js-yaml/node_modules/argparse/examples/help.js13
-rwxr-xr-xtools/eslint/node_modules/js-yaml/node_modules/argparse/examples/nargs.js33
-rwxr-xr-xtools/eslint/node_modules/js-yaml/node_modules/argparse/examples/parents.js28
-rwxr-xr-xtools/eslint/node_modules/js-yaml/node_modules/argparse/examples/prefix_chars.js23
-rwxr-xr-xtools/eslint/node_modules/js-yaml/node_modules/argparse/examples/sub_commands.js49
-rwxr-xr-xtools/eslint/node_modules/js-yaml/node_modules/argparse/examples/sum.js35
-rw-r--r--tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/testformatters.js270
10 files changed, 568 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/arguments.js b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/arguments.js
new file mode 100755
index 0000000000..5b090fa2e1
--- /dev/null
+++ b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/arguments.js
@@ -0,0 +1,36 @@
+#!/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: arguments'
+});
+parser.addArgument(
+ [ '-f', '--foo' ],
+ {
+ help: 'foo bar'
+ }
+);
+parser.addArgument(
+ [ '-b', '--bar' ],
+ {
+ help: 'bar foo'
+ }
+);
+
+
+parser.printHelp();
+console.log('-----------');
+
+var args;
+args = parser.parseArgs('-f 1 -b2'.split(' '));
+console.dir(args);
+console.log('-----------');
+args = parser.parseArgs('-f=3 --bar=4'.split(' '));
+console.dir(args);
+console.log('-----------');
+args = parser.parseArgs('--foo 5 --bar 6'.split(' '));
+console.dir(args);
+console.log('-----------');
diff --git a/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/choice.js b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/choice.js
new file mode 100755
index 0000000000..2616fa4d75
--- /dev/null
+++ b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/choice.js
@@ -0,0 +1,22 @@
+#!/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: choice'
+});
+
+parser.addArgument(['foo'], {choices: 'abc'});
+
+parser.printHelp();
+console.log('-----------');
+
+var args;
+args = parser.parseArgs(['c']);
+console.dir(args);
+console.log('-----------');
+parser.parseArgs(['X']);
+console.dir(args);
+
diff --git a/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/constants.js b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/constants.js
new file mode 100755
index 0000000000..172a4f3d4f
--- /dev/null
+++ b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/constants.js
@@ -0,0 +1,59 @@
+#!/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: constant'
+});
+
+parser.addArgument(
+ [ '-a'],
+ {
+ action: 'storeConst',
+ dest: 'answer',
+ help: 'store constant',
+ constant: 42
+ }
+);
+parser.addArgument(
+ [ '--str' ],
+ {
+ action: 'appendConst',
+ dest: 'types',
+ help: 'append constant "str" to types',
+ constant: 'str'
+ }
+);
+parser.addArgument(
+ [ '--int' ],
+ {
+ action: 'appendConst',
+ dest: 'types',
+ help: 'append constant "int" to types',
+ constant: 'int'
+ }
+);
+
+parser.addArgument(
+ [ '--true' ],
+ {
+ action: 'storeTrue',
+ help: 'store true constant'
+ }
+);
+parser.addArgument(
+ [ '--false' ],
+ {
+ action: 'storeFalse',
+ help: 'store false constant'
+ }
+);
+
+parser.printHelp();
+console.log('-----------');
+
+var args;
+args = parser.parseArgs('-a --str --int --true'.split(' '));
+console.dir(args);
diff --git a/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/help.js b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/help.js
new file mode 100755
index 0000000000..7eb955534f
--- /dev/null
+++ b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/help.js
@@ -0,0 +1,13 @@
+#!/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: help',
+ epilog: 'help epilog',
+ prog: 'help_example_prog',
+ usage: 'Usage %(prog)s <agrs>'
+});
+parser.printHelp();
diff --git a/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/nargs.js b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/nargs.js
new file mode 100755
index 0000000000..74f376beba
--- /dev/null
+++ b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/nargs.js
@@ -0,0 +1,33 @@
+#!/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: nargs'
+});
+parser.addArgument(
+ [ '-f', '--foo' ],
+ {
+ help: 'foo bar',
+ nargs: 1
+ }
+);
+parser.addArgument(
+ [ '-b', '--bar' ],
+ {
+ help: 'bar foo',
+ nargs: '*'
+ }
+);
+
+parser.printHelp();
+console.log('-----------');
+
+var args;
+args = parser.parseArgs('--foo a --bar c d'.split(' '));
+console.dir(args);
+console.log('-----------');
+args = parser.parseArgs('--bar b c f --foo a'.split(' '));
+console.dir(args);
diff --git a/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/parents.js b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/parents.js
new file mode 100755
index 0000000000..dfe896868b
--- /dev/null
+++ b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/parents.js
@@ -0,0 +1,28 @@
+#!/usr/bin/env node
+'use strict';
+
+var ArgumentParser = require('../lib/argparse').ArgumentParser;
+
+var args;
+var parent_parser = new ArgumentParser({ addHelp: false });
+// note addHelp:false to prevent duplication of the -h option
+parent_parser.addArgument(
+ ['--parent'],
+ { type: 'int', description: 'parent' }
+);
+
+var foo_parser = new ArgumentParser({
+ parents: [ parent_parser ],
+ description: 'child1'
+});
+foo_parser.addArgument(['foo']);
+args = foo_parser.parseArgs(['--parent', '2', 'XXX']);
+console.log(args);
+
+var bar_parser = new ArgumentParser({
+ parents: [ parent_parser ],
+ description: 'child2'
+});
+bar_parser.addArgument(['--bar']);
+args = bar_parser.parseArgs(['--bar', 'YYY']);
+console.log(args);
diff --git a/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/prefix_chars.js b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/prefix_chars.js
new file mode 100755
index 0000000000..430d5e1823
--- /dev/null
+++ b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/prefix_chars.js
@@ -0,0 +1,23 @@
+#!/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: prefix_chars',
+ prefixChars: '-+'
+});
+parser.addArgument(['+f', '++foo']);
+parser.addArgument(['++bar'], {action: 'storeTrue'});
+
+parser.printHelp();
+console.log('-----------');
+
+var args;
+args = parser.parseArgs(['+f', '1']);
+console.dir(args);
+args = parser.parseArgs(['++bar']);
+console.dir(args);
+args = parser.parseArgs(['++foo', '2', '++bar']);
+console.dir(args);
diff --git a/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/sub_commands.js b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/sub_commands.js
new file mode 100755
index 0000000000..df9c494440
--- /dev/null
+++ b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/sub_commands.js
@@ -0,0 +1,49 @@
+#!/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, help: 'c1 help'});
+bar.addArgument(
+ [ '-f', '--foo' ],
+ {
+ action: 'store',
+ help: 'foo3 bar3'
+ }
+);
+var bar = subparsers.addParser(
+ 'c2',
+ {aliases: ['co'], addHelp: true, help: 'c2 help'}
+);
+bar.addArgument(
+ [ '-b', '--bar' ],
+ {
+ action: 'store',
+ type: 'int',
+ help: 'foo3 bar3'
+ }
+);
+parser.printHelp();
+console.log('-----------');
+
+var args;
+args = parser.parseArgs('c1 -f 2'.split(' '));
+console.dir(args);
+console.log('-----------');
+args = parser.parseArgs('c2 -b 1'.split(' '));
+console.dir(args);
+console.log('-----------');
+args = parser.parseArgs('co -b 1'.split(' '));
+console.dir(args);
+console.log('-----------');
+parser.parseArgs(['c1', '-h']);
diff --git a/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/sum.js b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/sum.js
new file mode 100755
index 0000000000..4532800a50
--- /dev/null
+++ b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/sum.js
@@ -0,0 +1,35 @@
+#!/usr/bin/env node
+
+'use strict';
+
+
+var ArgumentParser = require('../lib/argparse').ArgumentParser;
+var parser = new ArgumentParser({ description: 'Process some integers.' });
+
+
+function sum(arr) {
+ return arr.reduce(function (a, b) {
+ return a + b;
+ }, 0);
+}
+function max(arr) {
+ return Math.max.apply(Math, arr);
+}
+
+
+parser.addArgument(['integers'], {
+ metavar: 'N',
+ type: 'int',
+ nargs: '+',
+ help: 'an integer for the accumulator'
+});
+parser.addArgument(['--sum'], {
+ dest: 'accumulate',
+ action: 'storeConst',
+ constant: sum,
+ defaultValue: max,
+ help: 'sum the integers (default: find the max)'
+});
+
+var args = parser.parseArgs('--sum 1 2 -1'.split(' '));
+console.log(args.accumulate(args.integers));
diff --git a/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/testformatters.js b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/testformatters.js
new file mode 100644
index 0000000000..1c03cdc843
--- /dev/null
+++ b/tools/eslint/node_modules/js-yaml/node_modules/argparse/examples/testformatters.js
@@ -0,0 +1,270 @@
+'use strict';
+
+var a, group, parser, helptext;
+
+var assert = require('assert');
+
+
+var print = function () {
+ return console.log.apply(console, arguments);
+ };
+// print = function () {};
+
+var argparse = require('argparse');
+
+print("TEST argparse.ArgumentDefaultsHelpFormatter");
+
+parser = new argparse.ArgumentParser({
+ debug: true,
+ formatterClass: argparse.ArgumentDefaultsHelpFormatter,
+ description: 'description'
+});
+
+parser.addArgument(['--foo'], {
+ help: 'foo help - oh and by the way, %(defaultValue)s'
+});
+
+parser.addArgument(['--bar'], {
+ action: 'storeTrue',
+ help: 'bar help'
+});
+
+parser.addArgument(['spam'], {
+ help: 'spam help'
+});
+
+parser.addArgument(['badger'], {
+ nargs: '?',
+ defaultValue: 'wooden',
+ help: 'badger help'
+});
+
+group = parser.addArgumentGroup({
+ title: 'title',
+ description: 'group description'
+});
+
+group.addArgument(['--baz'], {
+ type: 'int',
+ defaultValue: 42,
+ help: 'baz help'
+});
+
+helptext = parser.formatHelp();
+print(helptext);
+// test selected clips
+assert(helptext.match(/badger help \(default: wooden\)/));
+assert(helptext.match(/foo help - oh and by the way, null/));
+assert(helptext.match(/bar help \(default: false\)/));
+assert(helptext.match(/title:\n {2}group description/)); // test indent
+assert(helptext.match(/baz help \(default: 42\)/im));
+
+/*
+usage: PROG [-h] [--foo FOO] [--bar] [--baz BAZ] spam [badger]
+
+description
+
+positional arguments:
+ spam spam help
+ badger badger help (default: wooden)
+
+optional arguments:
+ -h, --help show this help message and exit
+ --foo FOO foo help - oh and by the way, null
+ --bar bar help (default: false)
+
+title:
+ group description
+
+ --baz BAZ baz help (default: 42)
+*/
+
+print("TEST argparse.RawDescriptionHelpFormatter");
+
+parser = new argparse.ArgumentParser({
+ debug: true,
+ prog: 'PROG',
+ formatterClass: argparse.RawDescriptionHelpFormatter,
+ description: 'Keep the formatting\n' +
+ ' exactly as it is written\n' +
+ '\n' +
+ 'here\n'
+});
+
+a = parser.addArgument(['--foo'], {
+ help: ' foo help should not\n' +
+ ' retain this odd formatting'
+});
+
+parser.addArgument(['spam'], {
+ 'help': 'spam help'
+});
+
+group = parser.addArgumentGroup({
+ title: 'title',
+ description: ' This text\n' +
+ ' should be indented\n' +
+ ' exactly like it is here\n'
+});
+
+group.addArgument(['--bar'], {
+ help: 'bar help'
+});
+
+helptext = parser.formatHelp();
+print(helptext);
+// test selected clips
+assert(helptext.match(parser.description));
+assert.equal(helptext.match(a.help), null);
+assert(helptext.match(/foo help should not retain this odd formatting/));
+
+/*
+class TestHelpRawDescription(HelpTestCase):
+ """Test the RawTextHelpFormatter"""
+....
+
+usage: PROG [-h] [--foo FOO] [--bar BAR] spam
+
+Keep the formatting
+ exactly as it is written
+
+here
+
+positional arguments:
+ spam spam help
+
+optional arguments:
+ -h, --help show this help message and exit
+ --foo FOO foo help should not retain this odd formatting
+
+title:
+ This text
+ should be indented
+ exactly like it is here
+
+ --bar BAR bar help
+*/
+
+
+print("TEST argparse.RawTextHelpFormatter");
+
+parser = new argparse.ArgumentParser({
+ debug: true,
+ prog: 'PROG',
+ formatterClass: argparse.RawTextHelpFormatter,
+ description: 'Keep the formatting\n' +
+ ' exactly as it is written\n' +
+ '\n' +
+ 'here\n'
+});
+
+parser.addArgument(['--baz'], {
+ help: ' baz help should also\n' +
+ 'appear as given here'
+});
+
+a = parser.addArgument(['--foo'], {
+ help: ' foo help should also\n' +
+ 'appear as given here'
+});
+
+parser.addArgument(['spam'], {
+ 'help': 'spam help'
+});
+
+group = parser.addArgumentGroup({
+ title: 'title',
+ description: ' This text\n' +
+ ' should be indented\n' +
+ ' exactly like it is here\n'
+});
+
+group.addArgument(['--bar'], {
+ help: 'bar help'
+});
+
+helptext = parser.formatHelp();
+print(helptext);
+// test selected clips
+assert(helptext.match(parser.description));
+assert(helptext.match(/( {14})appear as given here/gm));
+
+/*
+class TestHelpRawText(HelpTestCase):
+ """Test the RawTextHelpFormatter"""
+
+usage: PROG [-h] [--foo FOO] [--bar BAR] spam
+
+Keep the formatting
+ exactly as it is written
+
+here
+
+positional arguments:
+ spam spam help
+
+optional arguments:
+ -h, --help show this help message and exit
+ --foo FOO foo help should also
+ appear as given here
+
+title:
+ This text
+ should be indented
+ exactly like it is here
+
+ --bar BAR bar help
+*/
+
+
+print("TEST metavar as a tuple");
+
+parser = new argparse.ArgumentParser({
+ prog: 'PROG'
+});
+
+parser.addArgument(['-w'], {
+ help: 'w',
+ nargs: '+',
+ metavar: ['W1', 'W2']
+});
+
+parser.addArgument(['-x'], {
+ help: 'x',
+ nargs: '*',
+ metavar: ['X1', 'X2']
+});
+
+parser.addArgument(['-y'], {
+ help: 'y',
+ nargs: 3,
+ metavar: ['Y1', 'Y2', 'Y3']
+});
+
+parser.addArgument(['-z'], {
+ help: 'z',
+ nargs: '?',
+ metavar: ['Z1']
+});
+
+helptext = parser.formatHelp();
+print(helptext);
+var ustring = 'PROG [-h] [-w W1 [W2 ...]] [-x [X1 [X2 ...]]] [-y Y1 Y2 Y3] [-z [Z1]]';
+ustring = ustring.replace(/\[/g, '\\[').replace(/\]/g, '\\]');
+// print(ustring)
+assert(helptext.match(new RegExp(ustring)));
+
+/*
+class TestHelpTupleMetavar(HelpTestCase):
+ """Test specifying metavar as a tuple"""
+
+usage: PROG [-h] [-w W1 [W2 ...]] [-x [X1 [X2 ...]]] [-y Y1 Y2 Y3] [-z [Z1]]
+
+optional arguments:
+ -h, --help show this help message and exit
+ -w W1 [W2 ...] w
+ -x [X1 [X2 ...]] x
+ -y Y1 Y2 Y3 y
+ -z [Z1] z
+*/
+