1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-13 11:12:47 +00:00

updated bunch of file paths and changed the way posts are loaded

This commit is contained in:
2016-01-05 12:28:04 -06:00
parent 719ae331ae
commit c96a84d0ff
13249 changed files with 317868 additions and 2101398 deletions

21
node_modules/swig/node_modules/yargs/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
Copyright 2010 James Halliday (mail@substack.net)
This project is free software released under the MIT/X11 license:
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.

901
node_modules/swig/node_modules/yargs/README.md generated vendored Normal file
View File

@@ -0,0 +1,901 @@
yargs
========
Yargs be a node.js library fer hearties tryin' ter parse optstrings.
With yargs, ye be havin' a map that leads straight to yer treasure! Treasure of course, being a simple option hash.
[![Build Status](https://travis-ci.org/bcoe/yargs.png)](https://travis-ci.org/bcoe/yargs)
[![Dependency Status](https://gemnasium.com/bcoe/yargs.png)](https://gemnasium.com/bcoe/yargs)
[![Coverage Status](https://coveralls.io/repos/bcoe/yargs/badge.svg?branch=)](https://coveralls.io/r/bcoe/yargs?branch=)
[![NPM version](https://img.shields.io/npm/v/yargs.svg)](https://www.npmjs.com/package/yargs)
> Yargs is the official successor to optimist. Please feel free to submit issues and pull requests. If you'd like to contribute and don't know where to start, have a look at [the issue list](https://github.com/bcoe/yargs/issues) :)
examples
========
With yargs, the options be just a hash!
-------------------------------------------------------------------
xup.js:
````javascript
#!/usr/bin/env node
var argv = require('yargs').argv;
if (argv.rif - 5 * argv.xup > 7.138) {
console.log('Plunder more riffiwobbles!');
}
else {
console.log('Drop the xupptumblers!');
}
````
***
$ ./xup.js --rif=55 --xup=9.52
Plunder more riffiwobbles!
$ ./xup.js --rif 12 --xup 8.1
Drop the xupptumblers!
![Joe was one optimistic pirate.](http://i.imgur.com/4WFGVJ9.png)
But don't walk the plank just yet! There be more! You can do short options:
-------------------------------------------------
short.js:
````javascript
#!/usr/bin/env node
var argv = require('yargs').argv;
console.log('(%d,%d)', argv.x, argv.y);
````
***
$ ./short.js -x 10 -y 21
(10,21)
And booleans, both long, short, and even grouped:
----------------------------------
bool.js:
````javascript
#!/usr/bin/env node
var util = require('util');
var argv = require('yargs').argv;
if (argv.s) {
util.print(argv.fr ? 'Le perroquet dit: ' : 'The parrot says: ');
}
console.log(
(argv.fr ? 'couac' : 'squawk') + (argv.p ? '!' : '')
);
````
***
$ ./bool.js -s
The parrot says: squawk
$ ./bool.js -sp
The parrot says: squawk!
$ ./bool.js -sp --fr
Le perroquet dit: couac!
And non-hyphenated options too! Just use `argv._`!
-------------------------------------------------
nonopt.js:
````javascript
#!/usr/bin/env node
var argv = require('yargs').argv;
console.log('(%d,%d)', argv.x, argv.y);
console.log(argv._);
````
***
$ ./nonopt.js -x 6.82 -y 3.35 rum
(6.82,3.35)
[ 'rum' ]
$ ./nonopt.js "me hearties" -x 0.54 yo -y 1.12 ho
(0.54,1.12)
[ 'me hearties', 'yo', 'ho' ]
Yargs even counts your booleans!
----------------------------------------------------------------------
count.js
````javascript
#!/usr/bin/env node
var argv = require('yargs')
.count('verbose')
.alias('v', 'verbose')
.argv;
VERBOSE_LEVEL = argv.verbose;
function WARN() { VERBOSE_LEVEL >= 0 && console.log.apply(console, arguments); }
function INFO() { VERBOSE_LEVEL >= 1 && console.log.apply(console, arguments); }
function DEBUG() { VERBOSE_LEVEL >= 2 && console.log.apply(console, arguments); }
WARN("Showing only important stuff");
INFO("Showing semi-mportant stuff too");
DEBUG("Extra chatty mode");
````
***
$ node count.js
Showing only important stuff
$ node count.js -v
Showing only important stuff
Showing semi-important stuff too
$ node count.js -vv
Showing only important stuff
Showing semi-important stuff too
Extra chatty mode
$ node count.js -v --verbose
Showing only important stuff
Showing semi-important stuff too
Extra chatty mode
Tell users how to use yer options and make demands.
-------------------------------------------------
divide.js:
````javascript
#!/usr/bin/env node
var argv = require('yargs')
.usage('Usage: $0 -x [num] -y [num]')
.demand(['x','y'])
.argv;
console.log(argv.x / argv.y);
````
***
$ ./divide.js -x 55 -y 11
5
$ node ./divide.js -x 4.91 -z 2.51
Usage: node ./divide.js -x [num] -y [num]
Options:
-x [required]
-y [required]
Missing required arguments: y
After yer demands have been met, demand more! Ask for non-hypenated arguments!
-----------------------------------------
demand_count.js:
````javascript
#!/usr/bin/env node
var argv = require('yargs')
.demand(2)
.argv;
console.dir(argv)
````
***
$ ./demand_count.js a
Not enough arguments, expected 2, but only found 1
$ ./demand_count.js a b
{ _: [ 'a', 'b' ], '$0': 'node ./demand_count.js' }
$ ./demand_count.js a b c
{ _: [ 'a', 'b', 'c' ], '$0': 'node ./demand_count.js' }
EVEN MORE SHIVER ME TIMBERS!
------------------
default_singles.js:
````javascript
#!/usr/bin/env node
var argv = require('yargs')
.default('x', 10)
.default('y', 10)
.argv
;
console.log(argv.x + argv.y);
````
***
$ ./default_singles.js -x 5
15
default_hash.js:
````javascript
#!/usr/bin/env node
var argv = require('yargs')
.default({ x : 10, y : 10 })
.argv
;
console.log(argv.x + argv.y);
````
***
$ ./default_hash.js -y 7
17
And if you really want to get all descriptive about it...
---------------------------------------------------------
boolean_single.js
````javascript
#!/usr/bin/env node
var argv = require('yargs')
.boolean('v')
.argv
;
console.dir(argv.v);
console.dir(argv._);
````
***
$ ./boolean_single.js -v "me hearties" yo ho
true
[ 'me hearties', 'yo', 'ho' ]
boolean_double.js
````javascript
#!/usr/bin/env node
var argv = require('yargs')
.boolean(['x','y','z'])
.argv
;
console.dir([ argv.x, argv.y, argv.z ]);
console.dir(argv._);
````
***
$ ./boolean_double.js -x -z one two three
[ true, false, true ]
[ 'one', 'two', 'three' ]
Yargs is here to help you...
---------------------------
Ye can describe parameters fer help messages and set aliases. Yargs figures
out how ter format a handy help string automatically.
line_count.js
````javascript
#!/usr/bin/env node
var argv = require('yargs')
.usage('Usage: $0 <command> [options]')
.command('count', 'Count the lines in a file')
.demand(1)
.example('$0 count -f foo.js', 'count the lines in the given file')
.demand('f')
.alias('f', 'file')
.nargs('f', 1)
.describe('f', 'Load a file')
.help('h')
.alias('h', 'help')
.epilog('copyright 2015')
.argv;
var fs = require('fs');
var s = fs.createReadStream(argv.file);
var lines = 0;
s.on('data', function (buf) {
lines += buf.toString().match(/\n/g).length;
});
s.on('end', function () {
console.log(lines);
});
````
***
$ node line_count.js count
Usage: node test.js <command> [options]
Commands:
count Count the lines in a file
Options:
-f, --file Load a file [required]
-h, --help Show help
Examples:
node test.js count -f foo.js count the lines in the given file
copyright 2015
Missing required arguments: f
$ node line_count.js count --file line_count.js
20
$ node line_count.js count -f line_count.js
20
methods
=======
By itself,
````javascript
require('yargs').argv
`````
will use `process.argv` array to construct the `argv` object.
You can pass in the `process.argv` yourself:
````javascript
require('yargs')([ '-x', '1', '-y', '2' ]).argv
````
or use .parse() to do the same thing:
````javascript
require('yargs').parse([ '-x', '1', '-y', '2' ])
````
The rest of these methods below come in just before the terminating `.argv`.
.alias(key, alias)
------------------
Set key names as equivalent such that updates to a key will propagate to aliases
and vice-versa.
Optionally `.alias()` can take an object that maps keys to aliases.
Each key of this object should be the canonical version of the option, and each
value should be a string or an array of strings.
.default(key, value, [description])
--------------------
Set `argv[key]` to `value` if no option was specified on `process.argv`.
Optionally `.default()` can take an object that maps keys to default values.
But wait, there's more! the default value can be a `function` which returns
a value. The name of the function will be used in the usage string:
```js
var argv = require('yargs')
.default('random', function randomValue() {
return Math.random() * 256;
}).argv;
```
Optionally, `description` can also be provided and will take precedence over
displaying the value in the usage instructions:
```js
.default('timeout', 60000, '(one-minute)');
```
.demand(key, [msg | boolean])
-----------------------------
.require(key, [msg | boolean])
------------------------------
.required(key, [msg | boolean])
-------------------------------
If `key` is a string, show the usage information and exit if `key` wasn't
specified in `process.argv`.
If `key` is a number, demand at least as many non-option arguments, which show
up in `argv._`.
If `key` is an Array, demand each element.
If a `msg` string is given, it will be printed when the argument is missing,
instead of the standard error message. This is especially helpful for the non-option arguments in `argv._`.
If a `boolean` value is given, it controls whether the option is demanded;
this is useful when using `.options()` to specify command line parameters.
.requiresArg(key)
-----------------
Specifies either a single option key (string), or an array of options that
must be followed by option values. If any option value is missing, show the
usage information and exit.
The default behaviour is to set the value of any key not followed by an
option value to `true`.
.implies(x, y)
--------------
Given the key `x` is set, it is required that the key `y` is set.
implies can also accept an object specifying multiple implications.
.describe(key, desc)
--------------------
Describe a `key` for the generated usage information.
Optionally `.describe()` can take an object that maps keys to descriptions.
.option(key, opt)
-----------------
.options(key, opt)
------------------
Instead of chaining together `.alias().demand().default().describe().string()`, you can specify
keys in `opt` for each of the chainable methods.
For example:
````javascript
var argv = require('yargs')
.option('f', {
alias : 'file',
demand: true,
default: '/etc/passwd',
describe: 'x marks the spot',
type: 'string'
})
.argv
;
````
is the same as
````javascript
var argv = require('yargs')
.alias('f', 'file')
.default('f', '/etc/passwd')
.argv
;
````
Optionally `.options()` can take an object that maps keys to `opt` parameters.
````javascript
var argv = require('yargs')
.options({
'f': {
alias: 'file',
demand: true,
default: '/etc/passwd',
describe: 'x marks the spot',
type: 'string'
}
})
.argv
;
````
.usage(message, opts)
---------------------
Set a usage message to show which commands to use. Inside `message`, the string
`$0` will get interpolated to the current script name or node command for the
present script similar to how `$0` works in bash or perl.
`opts` is optional and acts like calling `.options(opts)`.
.command(cmd, desc)
-------------------
Document the commands exposed by your application (stored in the `_` variable).
As an example, here's how the npm cli might document some of its commands:
```js
var argv = require('yargs')
.usage('npm <command>')
.command('install', 'tis a mighty fine package to install')
.command('publish', 'shiver me timbers, should you be sharing all that')
.argv;
```
.example(cmd, desc)
-------------------
Give some example invocations of your program. Inside `cmd`, the string
`$0` will get interpolated to the current script name or node command for the
present script similar to how `$0` works in bash or perl.
Examples will be printed out as part of the help message.
.epilogue(str)
--------------
.epilog(str)
------------
A message to print at the end of the usage instructions, e.g.,
```js
var argv = require('yargs')
.epilogue('for more information, find our manual at http://example.com');
```
.check(fn)
----------
Check that certain conditions are met in the provided arguments.
`fn` is called with two arguments, the parsed `argv` hash and an array of options and their aliases.
If `fn` throws or returns a non-truthy value, show the thrown error, usage information, and
exit.
.fail(fn)
---------
Method to execute when a failure occurs, rather then printing the failure message.
`fn` is called with the failure message that would have been printed.
.boolean(key)
-------------
Interpret `key` as a boolean. If a non-flag option follows `key` in
`process.argv`, that string won't get set as the value of `key`.
`key` will default to `false`, unless an `default(key, undefined)` is
explicitly set.
If `key` is an Array, interpret all the elements as booleans.
.string(key)
------------
Tell the parser logic not to interpret `key` as a number or boolean.
This can be useful if you need to preserve leading zeros in an input.
If `key` is an Array, interpret all the elements as strings.
`.string('_')` will result in non-hyphenated arguments being interpreted as strings,
regardless of whether they resemble numbers.
.array(key)
----------
Tell the parser to interpret `key` as an array. If `.array('foo')` is set,
`--foo bar` will be parsed as `['bar']` rather than as `'bar'`.
.nargs(key, count)
-----------
The number of arguments that should be consumed after a key. This can be a
useful hint to prevent parsing ambiguity:
```js
var argv = require('yargs')
.nargs('token', 1)
.parse(['--token', '-my-token']);
```
parses as:
`{ _: [], token: '-my-token', '$0': 'node test' }`
Optionally `.nargs()` can take an object of `key`/`narg` pairs.
.config(key)
------------
Tells the parser to interpret `key` as a path to a JSON config file. The file
is loaded and parsed, and its properties are set as arguments.
.wrap(columns)
--------------
Format usage output to wrap at `columns` many columns.
By default wrap will be set to `Math.min(80, windowWidth)`. Use `.wrap(null)` to
specify no column limit.
.strict()
---------
Any command-line argument given that is not demanded, or does not have a
corresponding description, will be reported as an error.
.help([option, [description]])
------------------------------
Add an option (e.g., `--help`) that displays the usage string and exits the
process. If present, the `description` parameter customises the description of
the help option in the usage string.
If invoked without parameters, `.help` returns the generated usage string.
Example:
```
var yargs = require("yargs")
.usage("$0 -operand1 number -operand2 number -operation [add|subtract]");
console.log(yargs.help());
```
Later on, ```argv``` can be retrived with ```yargs.argv```
.version(version, [option], [description])
----------------------------------------
Add an option (e.g., `--version`) that displays the version number (given by the
`version` parameter) and exits the process. If present, the `description`
parameter customizes the description of the version option in the usage string.
You can provide a `function` for version, rather than a string.
This is useful if you want to use the version from your package.json:
```js
var argv = require('yargs')
.version(function() {
return require('../package').version;
})
.argv;
```
.showHelpOnFail(enable, [message])
----------------------------------
By default, yargs outputs a usage string if any error is detected. Use the
`.showHelpOnFail` method to customize this behaviour. if `enable` is `false`,
the usage string is not output. If the `message` parameter is present, this
message is output after the error message.
line_count.js
````javascript
#!/usr/bin/env node
var argv = require('yargs')
.usage('Count the lines in a file.\nUsage: $0')
.demand('f')
.alias('f', 'file')
.describe('f', 'Load a file')
.showHelpOnFail(false, "Specify --help for available options")
.argv;
// etc.
````
***
$ node line_count.js --file
Missing argument value: f
Specify --help for available options
.showHelp(fn=console.error)
---------------------------
Print the usage data using `fn` for printing.
Example:
```
var yargs = require("yargs")
.usage("$0 -operand1 number -operand2 number -operation [add|subtract]");
yargs.showHelp();
```
Later on, ```argv``` can be retrived with ```yargs.argv```
.completion(cmd, [description], [fn]);
-------------
Enable bash-completion shortcuts for commands and options.
`cmd`: when present in `argv._`, will result in the `.bashrc` completion script
being outputted. To enable bash completions, concat the generated script to your
`.bashrc`, or `.bash_profile`.
`description`: provide a description in your usage instructions for the command
that generates bash completion scripts.
`fn`, rather than relying on yargs' default completion functionlity, which
shiver me timbers is pretty awesome, you can provide your own completion
method.
```js
var argv = require('yargs')
.completion('completion', function(current, argv) {
// 'current' is the current command being completed.
// 'argv' is the parsed arguments so far.
// simply return an array of completions.
return [
'foo',
'bar'
];
})
.argv;
```
But wait, there's more! you can provide asynchronous completions.
```js
var argv = require('yargs')
.completion('completion', function(current, argv, done) {
setTimeout(function() {
done([
'apple',
'banana'
]);
}, 500);
})
.argv;
```
.showCompletionScript()
----------------------
Generate a bash completion script. Users of your application can install this
script in their `.bashrc`, and yargs will provide completion shortcuts for
commands and options.
.exitProcess(enable)
----------------------------------
By default, yargs exits the process when the user passes a help flag, uses the `.version` functionality or when validation fails. Calling `.exitProcess(false)` disables this behavior, enabling further actions after yargs have been validated.
.parse(args)
------------
Parse `args` instead of `process.argv`. Returns the `argv` object.
.reset()
--------
Reset the argument object built up so far. This is useful for
creating nested command line interfaces.
```js
var yargs = require('./yargs')
.usage('$0 command')
.command('hello', 'hello command')
.command('world', 'world command')
.demand(1, 'must provide a valid command'),
argv = yargs.argv,
command = argv._[0];
if (command === 'hello') {
yargs.reset()
.usage('$0 hello')
.help('h')
.example('$0 hello', 'print the hello message!')
.argv
console.log('hello!');
} else if (command === 'world'){
yargs.reset()
.usage('$0 world')
.help('h')
.example('$0 world', 'print the world message!')
.argv
console.log('world!');
} else {
yargs.showHelp();
}
```
.argv
-----
Get the arguments as a plain old object.
Arguments without a corresponding flag show up in the `argv._` array.
The script name or node command is available at `argv.$0` similarly to how `$0`
works in bash or perl.
parsing tricks
==============
stop parsing
------------
Use `--` to stop parsing flags and stuff the remainder into `argv._`.
$ node examples/reflect.js -a 1 -b 2 -- -c 3 -d 4
{ _: [ '-c', '3', '-d', '4' ],
'$0': 'node ./examples/reflect.js',
a: 1,
b: 2 }
negate fields
-------------
If you want to explicity set a field to false instead of just leaving it
undefined or to override a default you can do `--no-key`.
$ node examples/reflect.js -a --no-b
{ _: [],
'$0': 'node ./examples/reflect.js',
a: true,
b: false }
numbers
-------
Every argument that looks like a number (`!isNaN(Number(arg))`) is converted to
one. This way you can just `net.createConnection(argv.port)` and you can add
numbers out of `argv` with `+` without having that mean concatenation,
which is super frustrating.
duplicates
----------
If you specify a flag multiple times it will get turned into an array containing
all the values in order.
$ node examples/reflect.js -x 5 -x 8 -x 0
{ _: [],
'$0': 'node ./examples/reflect.js',
x: [ 5, 8, 0 ] }
dot notation
------------
When you use dots (`.`s) in argument names, an implicit object path is assumed.
This lets you organize arguments into nested objects.
$ node examples/reflect.js --foo.bar.baz=33 --foo.quux=5
{ _: [],
'$0': 'node ./examples/reflect.js',
foo: { bar: { baz: 33 }, quux: 5 } }
short numbers
-------------
Short numeric `head -n5` style argument work too:
$ node reflect.js -n123 -m456
{ '3': true,
'6': true,
_: [],
'$0': 'node ./reflect.js',
n: 123,
m: 456 }
installation
============
With [npm](http://github.com/isaacs/npm), just do:
npm install yargs
or clone this project on github:
git clone http://github.com/bcoe/yargs.git
To run the tests with npm, just do:
npm test
inspired by
===========
This module is loosely inspired by Perl's
[Getopt::Casual](http://search.cpan.org/~photo/Getopt-Casual-0.13.1/Casual.pm).

22
node_modules/swig/node_modules/yargs/completion.sh.hbs generated vendored Normal file
View File

@@ -0,0 +1,22 @@
###-begin-{{app_name}}-completions-###
#
# yargs command completion script
#
# Installation: {{app_path}} completion >> ~/.bashrc
# or {{app_path}} completion >> ~/.bash_profile on OSX.
#
_yargs_completions()
{
local cur_word args type_list
cur_word="${COMP_WORDS[COMP_CWORD]}"
args=$(printf "%s " "${COMP_WORDS[@]}")
# ask yargs to generate completions.
type_list=`{{app_path}} --get-yargs-completions $args`
COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )
return 0
}
complete -F _yargs_completions {{app_name}}
###-end-{{app_name}}-completions-###

489
node_modules/swig/node_modules/yargs/index.js generated vendored Normal file
View File

@@ -0,0 +1,489 @@
var assert = require('assert'),
path = require('path'),
Completion = require('./lib/completion'),
Parser = require('./lib/parser'),
Usage = require('./lib/usage'),
Validation = require('./lib/validation');
Argv(process.argv.slice(2));
var exports = module.exports = Argv;
function Argv (processArgs, cwd) {
processArgs = processArgs || []; // handle calling yargs().
var self = {};
var completion = null;
var usage = null;
var validation = null;
if (!cwd) cwd = process.cwd();
self.$0 = process.argv
.slice(0,2)
.map(function (x) {
// ignore the node bin, specify this in your
// bin file with #!/usr/bin/env node
if (~x.indexOf('node')) return;
var b = rebase(cwd, x);
return x.match(/^\//) && b.length < x.length
? b : x
})
.join(' ').trim();
;
if (process.env._ != undefined && process.argv[1] == process.env._) {
self.$0 = process.env._.replace(
path.dirname(process.execPath) + '/', ''
);
}
var options;
self.resetOptions = self.reset = function () {
// put yargs back into its initial
// state, this is useful for creating a
// nested CLI.
options = {
array: [],
boolean: [],
string: [],
narg: {},
key: {},
alias: {},
default: {},
defaultDescription: {},
requiresArg: [],
count: [],
normalize: [],
config: []
};
usage = Usage(self); // handle usage output.
validation = Validation(self, usage); // handle arg validation.
completion = Completion(self, usage);
demanded = {};
exitProcess = true;
strict = false;
helpOpt = null;
versionOpt = null;
completionOpt = null;
return self;
};
self.resetOptions();
self.boolean = function (bools) {
options.boolean.push.apply(options.boolean, [].concat(bools));
return self;
};
self.array = function (arrays) {
options.array.push.apply(options.array, [].concat(arrays));
return self;
}
self.nargs = function (key, n) {
if (typeof key === 'object') {
Object.keys(key).forEach(function(k) {
self.nargs(k, key[k]);
});
} else {
options.narg[key] = n;
}
return self;
}
self.normalize = function (strings) {
options.normalize.push.apply(options.normalize, [].concat(strings));
return self;
};
self.config = function (configs) {
options.config.push.apply(options.config, [].concat(configs));
return self;
};
self.example = function (cmd, description) {
usage.example(cmd, description);
return self;
};
self.command = function (cmd, description) {
usage.command(cmd, description);
return self;
};
self.string = function (strings) {
options.string.push.apply(options.string, [].concat(strings));
return self;
};
self.default = function (key, value, defaultDescription) {
if (typeof key === 'object') {
Object.keys(key).forEach(function (k) {
self.default(k, key[k]);
});
}
else {
options.defaultDescription[key] = defaultDescription;
options.default[key] = value;
}
return self;
};
self.alias = function (x, y) {
if (typeof x === 'object') {
Object.keys(x).forEach(function (key) {
self.alias(key, x[key]);
});
}
else {
options.alias[x] = (options.alias[x] || []).concat(y);
}
return self;
};
self.count = function(counts) {
options.count.push.apply(options.count, [].concat(counts));
return self;
};
var demanded = {};
self.demand = self.required = self.require = function (keys, msg) {
if (typeof keys == 'number') {
if (!demanded._) demanded._ = { count: 0, msg: null };
demanded._.count += keys;
demanded._.msg = msg;
}
else if (Array.isArray(keys)) {
keys.forEach(function (key) {
self.demand(key, msg);
});
}
else {
if (typeof msg === 'string') {
demanded[keys] = { msg: msg };
}
else if (msg === true || typeof msg === 'undefined') {
demanded[keys] = { msg: null };
}
}
return self;
};
self.getDemanded = function() {
return demanded;
};
self.requiresArg = function (requiresArgs) {
options.requiresArg.push.apply(options.requiresArg, [].concat(requiresArgs));
return self;
};
self.implies = function (key, value) {
validation.implies(key, value);
return self;
};
self.usage = function (msg, opts) {
if (!opts && typeof msg === 'object') {
opts = msg;
msg = null;
}
usage.usage(msg);
if (opts) self.options(opts);
return self;
};
self.epilogue = self.epilog = function (msg) {
usage.epilog(msg);
return self;
};
self.fail = function (f) {
usage.failFn(f);
return self;
};
self.check = function (f) {
validation.check(f);
return self;
};
self.defaults = self.default;
self.describe = function (key, desc) {
usage.describe(key, desc);
return self;
};
self.parse = function (args) {
return parseArgs(args);
};
self.option = self.options = function (key, opt) {
if (typeof key === 'object') {
Object.keys(key).forEach(function (k) {
self.options(k, key[k]);
});
}
else {
assert(typeof opt === 'object', 'second argument to option must be an object');
options.key[key] = true; // track manually set keys.
if (opt.alias) self.alias(key, opt.alias);
var demand = opt.demand || opt.required || opt.require;
if (demand) {
self.demand(key, demand);
}
if ('default' in opt) {
self.default(key, opt.default);
}
if ('nargs' in opt) {
self.nargs(key, opt.nargs);
}
if (opt.boolean || opt.type === 'boolean') {
self.boolean(key);
if (opt.alias) self.boolean(opt.alias);
}
if (opt.array || opt.type === 'array') {
self.array(key);
if (opt.alias) self.array(opt.alias);
}
if (opt.string || opt.type === 'string') {
self.string(key);
if (opt.alias) self.string(opt.alias);
}
if (opt.count || opt.type === 'count') {
self.count(key);
}
var desc = opt.describe || opt.description || opt.desc;
if (desc) {
self.describe(key, desc);
}
if (opt.requiresArg) {
self.requiresArg(key);
}
}
return self;
};
self.getOptions = function() {
return options;
};
self.wrap = function (cols) {
usage.wrap(cols);
return self;
};
var strict = false;
self.strict = function () {
strict = true;
return self;
};
self.getStrict = function () {
return strict;
}
self.showHelp = function (fn) {
usage.showHelp(fn);
return self;
};
var versionOpt = null;
self.version = function (ver, opt, msg) {
versionOpt = opt || 'version';
usage.version(ver);
self.describe(versionOpt, msg || 'Show version number');
return self;
};
var helpOpt = null;
self.addHelpOpt = function (opt, msg) {
helpOpt = opt;
self.describe(opt, msg || 'Show help');
return self;
};
self.showHelpOnFail = function (enabled, message) {
usage.showHelpOnFail(enabled, message);
return self;
};
var exitProcess = true;
self.exitProcess = function (enabled) {
if (typeof enabled !== 'boolean') {
enabled = true;
}
exitProcess = enabled;
return self;
};
self.getExitProcess = function () {
return exitProcess;
}
self.help = function () {
if (arguments.length > 0) return self.addHelpOpt.apply(self, arguments);
if (!self.parsed) parseArgs(processArgs); // run parser, if it has not already been executed.
return usage.help();
};
var completionOpt = null,
completionCommand = null;
self.completion = function(cmd, desc, fn) {
// a function to execute when generating
// completions can be provided as the second
// or third argument to completion.
if (typeof desc === 'function') {
fn = desc;
desc = null;
}
// register the completion command.
completionCommand = cmd;
completionOpt = completion.completionKey;
self.command(completionCommand, desc || 'generate bash completion script');
// a function can be provided
if (fn) completion.registerFunction(fn);
return self;
};
self.showCompletionScript = function($0) {
$0 = $0 || self.$0;
console.log(completion.generateCompletionScript($0));
return self;
};
self.getUsageInstance = function () {
return usage;
};
self.getValidationInstance = function () {
return validation;
}
Object.defineProperty(self, 'argv', {
get : function () {
var args = null;
try {
args = parseArgs(processArgs);
} catch (err) {
usage.fail(err.message);
}
return args;
},
enumerable : true
});
function parseArgs (args) {
var parsed = Parser(args, options),
argv = parsed.argv,
aliases = parsed.aliases;
argv.$0 = self.$0;
self.parsed = parsed;
// generate a completion script for adding to ~/.bashrc.
if (completionCommand && ~argv._.indexOf(completionCommand)) {
self.showCompletionScript();
if (exitProcess){
process.exit(0);
}
}
Object.keys(argv).forEach(function(key) {
if (key === helpOpt) {
self.showHelp('log');
if (exitProcess){
process.exit(0);
}
}
else if (key === versionOpt) {
usage.showVersion();
if (exitProcess){
process.exit(0);
}
}
else if (key === completionOpt) {
// we allow for asynchronous completions,
// e.g., loading in a list of commands from an API.
completion.getCompletion(function(completions) {
(completions || []).forEach(function(completion) {
console.log(completion);
});
if (exitProcess){
process.exit(0);
}
});
return;
}
});
validation.nonOptionCount(argv);
validation.missingArgumentValue(argv);
validation.requiredArguments(argv);
if (strict) {
validation.unknownArguments(argv, aliases);
}
validation.customChecks(argv, aliases);
validation.implications(argv);
setPlaceholderKeys(argv);
return argv;
}
function setPlaceholderKeys (argv) {
Object.keys(options.key).forEach(function(key) {
if (typeof argv[key] === 'undefined') argv[key] = undefined;
});
}
sigletonify(self);
return self;
};
// rebase an absolute path to a relative one with respect to a base directory
// exported for tests
exports.rebase = rebase;
function rebase (base, dir) {
return path.relative(base, dir);
};
/* Hack an instance of Argv with process.argv into Argv
so people can do
require('yargs')(['--beeble=1','-z','zizzle']).argv
to parse a list of args and
require('yargs').argv
to get a parsed version of process.argv.
*/
function sigletonify(inst) {
Object.keys(inst).forEach(function (key) {
if (key === 'argv') {
Argv.__defineGetter__(key, inst.__lookupGetter__(key));
} else {
Argv[key] = typeof inst[key] == 'function'
? inst[key].bind(inst)
: inst[key];
}
});
}

71
node_modules/swig/node_modules/yargs/lib/completion.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
var fs = require('fs'),
path = require('path');
// add bash completions to your
// yargs-powered applications.
module.exports = function (yargs, usage) {
var self = {
completionKey: 'get-yargs-completions'
};
// get a list of completion commands.
self.getCompletion = function (done) {
var completions = [],
current = process.argv[process.argv.length - 1],
previous = process.argv.slice(process.argv.indexOf('--' + self.completionKey) + 1),
argv = yargs.parse(previous);
// a custom completion function can be provided
// to completion().
if (completionFunction) {
if (completionFunction.length < 3) {
// synchronous completion function.
return done(completionFunction(current, argv));
} else {
// asynchronous completion function
return completionFunction(current, argv, function(completions) {
done(completions);
});
}
}
if (!current.match(/^-/)) {
usage.getCommands().forEach(function(command) {
completions.push(command[0]);
});
}
if (current.match(/^-/)) {
Object.keys(yargs.getOptions().key).forEach(function(key) {
completions.push('--' + key);
});
}
done(completions);
};
// generate the completion script to add to your .bashrc.
self.generateCompletionScript = function ($0) {
var script = fs.readFileSync(
path.resolve(__dirname, '../completion.sh.hbs'),
'utf-8'
),
name = path.basename($0);
// add ./to applications not yet installed as bin.
if ($0.match(/\.js$/)) $0 = './' + $0;
script = script.replace(/{{app_name}}/g, name);
return script.replace(/{{app_path}}/g, $0);
};
// register a function to perform your own custom
// completions., this function can be either
// synchrnous or asynchronous.
var completionFunction = null;
self.registerFunction = function (fn) {
completionFunction = fn;
}
return self;
};

407
node_modules/swig/node_modules/yargs/lib/parser.js generated vendored Normal file
View File

@@ -0,0 +1,407 @@
// fancy-pants parsing of argv, originally forked
// from minimist: https://www.npmjs.com/package/minimist
var camelCase = require('camelcase'),
fs = require('fs'),
path = require('path');
module.exports = function (args, opts) {
if (!opts) opts = {};
var flags = { arrays: {}, bools : {}, strings : {}, counts: {}, normalize: {}, configs: {} };
[].concat(opts['array']).filter(Boolean).forEach(function (key) {
flags.arrays[key] = true;
});
[].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
flags.bools[key] = true;
});
[].concat(opts.string).filter(Boolean).forEach(function (key) {
flags.strings[key] = true;
});
[].concat(opts.count).filter(Boolean).forEach(function (key) {
flags.counts[key] = true;
});
[].concat(opts.normalize).filter(Boolean).forEach(function (key) {
flags.normalize[key] = true;
});
[].concat(opts.config).filter(Boolean).forEach(function (key) {
flags.configs[key] = true;
});
var aliases = {},
newAliases = {};
extendAliases(opts.key);
extendAliases(opts.alias);
var defaults = opts['default'] || {};
Object.keys(defaults).forEach(function (key) {
if (/-/.test(key) && !opts.alias[key]) {
var c = camelCase(key);
aliases[key] = aliases[key] || [];
// don't allow the same key to be added multiple times.
if (aliases[key].indexOf(c) === -1) {
aliases[key] = (aliases[key] || []).concat(c);
newAliases[c] = true;
}
}
(aliases[key] || []).forEach(function (alias) {
defaults[alias] = defaults[key];
});
});
var argv = { _ : [] };
Object.keys(flags.bools).forEach(function (key) {
setArg(key, !(key in defaults) ? false : defaults[key]);
});
var notFlags = [];
if (args.indexOf('--') !== -1) {
notFlags = args.slice(args.indexOf('--')+1);
args = args.slice(0, args.indexOf('--'));
}
for (var i = 0; i < args.length; i++) {
var arg = args[i];
// -- seperated by =
if (arg.match(/^--.+=/)) {
// Using [\s\S] instead of . because js doesn't support the
// 'dotall' regex modifier. See:
// http://stackoverflow.com/a/1068308/13216
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
setArg(m[1], m[2]);
}
else if (arg.match(/^--no-.+/)) {
var key = arg.match(/^--no-(.+)/)[1];
setArg(key, false);
}
// -- seperated by space.
else if (arg.match(/^--.+/)) {
var key = arg.match(/^--(.+)/)[1];
if (checkAllAliases(key, opts.narg)) {
i = eatNargs(i, key, args);
} else {
var next = args[i + 1];
if (next !== undefined && !next.match(/^-/)
&& !checkAllAliases(key, flags.bools)
&& !checkAllAliases(key, flags.counts)) {
setArg(key, next);
i++;
}
else if (/^(true|false)$/.test(next)) {
setArg(key, next);
i++;
}
else {
setArg(key, defaultForType(guessType(key, flags)));
}
}
}
// dot-notation flag seperated by '='.
else if (arg.match(/^-.\..+=/)) {
var m = arg.match(/^-([^=]+)=([\s\S]*)$/);
setArg(m[1], m[2]);
}
// dot-notation flag seperated by space.
else if (arg.match(/^-.\..+/)) {
var key = arg.match(/^-(.\..+)/)[1];
var next = args[i + 1];
if (next !== undefined && !next.match(/^-/)
&& !checkAllAliases(key, flags.bools)
&& !checkAllAliases(key, flags.counts)) {
setArg(key, next);
i++;
}
else {
setArg(key, defaultForType(guessType(key, flags)));
}
}
else if (arg.match(/^-[^-]+/)) {
var letters = arg.slice(1,-1).split('');
var broken = false;
for (var j = 0; j < letters.length; j++) {
var next = arg.slice(j+2);
if (letters[j+1] && letters[j+1] === '=') {
setArg(letters[j], arg.slice(j+3));
broken = true;
break;
}
if (next === '-') {
setArg(letters[j], next)
continue;
}
if (/[A-Za-z]/.test(letters[j])
&& /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
setArg(letters[j], next);
broken = true;
break;
}
if (letters[j+1] && letters[j+1].match(/\W/)) {
setArg(letters[j], arg.slice(j+2));
broken = true;
break;
}
else {
setArg(letters[j], defaultForType(guessType(letters[j], flags)));
}
}
var key = arg.slice(-1)[0];
if (!broken && key !== '-') {
if (checkAllAliases(key, opts.narg)) {
i = eatNargs(i, key, args);
} else {
if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
&& !checkAllAliases(key, flags.bools)
&& !checkAllAliases(key, flags.counts)) {
setArg(key, args[i+1]);
i++;
}
else if (args[i+1] && /true|false/.test(args[i+1])) {
setArg(key, args[i+1]);
i++;
}
else {
setArg(key, defaultForType(guessType(key, flags)));
}
}
}
}
else {
argv._.push(
flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
);
}
}
setConfig(argv);
applyDefaultsAndAliases(argv, aliases, defaults);
Object.keys(flags.counts).forEach(function (key) {
setArg(key, defaults[key]);
});
notFlags.forEach(function(key) {
argv._.push(key);
});
// how many arguments should we consume, based
// on the nargs option?
function eatNargs (i, key, args) {
var toEat = checkAllAliases(key, opts.narg);
if (args.length - (i + 1) < toEat) throw Error('not enough arguments following: ' + key);
for (var ii = i + 1; ii < (toEat + i + 1); ii++) {
setArg(key, args[ii]);
}
return (i + toEat);
}
function setArg (key, val) {
// handle parsing boolean arguments --foo=true --bar false.
if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) {
if (typeof val === 'string') val = val === 'true';
}
if (/-/.test(key) && !(aliases[key] && aliases[key].length)) {
var c = camelCase(key);
aliases[key] = [c];
newAliases[c] = true;
}
var value = !checkAllAliases(key, flags.strings) && isNumber(val) ? Number(val) : val;
if (checkAllAliases(key, flags.counts)) {
value = function(orig) { return orig !== undefined ? orig + 1 : 0; };
}
var splitKey = key.split('.');
setKey(argv, splitKey, value);
(aliases[splitKey[0]] || []).forEach(function (x) {
x = x.split('.');
// handle populating dot notation for both
// the key and its aliases.
if (splitKey.length > 1) {
var a = [].concat(splitKey);
a.shift(); // nuke the old key.
x = x.concat(a);
}
setKey(argv, x, value);
});
var keys = [key].concat(aliases[key] || []);
for (var i = 0, l = keys.length; i < l; i++) {
if (flags.normalize[keys[i]]) {
keys.forEach(function(key) {
argv.__defineSetter__(key, function(v) {
val = path.normalize(v);
});
argv.__defineGetter__(key, function () {
return typeof val === 'string' ?
path.normalize(val) : val;
});
});
break;
}
}
}
// set args from config.json file, this should be
// applied last so that defaults can be applied.
function setConfig (argv) {
var configLookup = {};
// expand defaults/aliases, in-case any happen to reference
// the config.json file.
applyDefaultsAndAliases(configLookup, aliases, defaults);
Object.keys(flags.configs).forEach(function(configKey) {
var configPath = argv[configKey] || configLookup[configKey];
if (configPath) {
try {
var config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
Object.keys(config).forEach(function (key) {
// setting arguments via CLI takes precedence over
// values within the config file.
if (argv[key] === undefined) {
delete argv[key];
setArg(key, config[key]);
}
});
} catch (ex) {
throw Error('invalid json config file: ' + configPath);
}
}
});
}
function applyDefaultsAndAliases(obj, aliases, defaults) {
Object.keys(defaults).forEach(function (key) {
if (!hasKey(obj, key.split('.'))) {
setKey(obj, key.split('.'), defaults[key]);
(aliases[key] || []).forEach(function (x) {
setKey(obj, x.split('.'), defaults[key]);
});
}
});
}
function hasKey (obj, keys) {
var o = obj;
keys.slice(0,-1).forEach(function (key) {
o = (o[key] || {});
});
var key = keys[keys.length - 1];
return key in o;
}
function setKey (obj, keys, value) {
var o = obj;
keys.slice(0,-1).forEach(function (key) {
if (o[key] === undefined) o[key] = {};
o = o[key];
});
var key = keys[keys.length - 1];
if (typeof value === 'function') {
o[key] = value(o[key]);
}
else if (o[key] === undefined && checkAllAliases(key, flags.arrays)) {
o[key] = Array.isArray(value) ? value : [value];
}
else if (o[key] === undefined || typeof o[key] === 'boolean') {
o[key] = value;
}
else if (Array.isArray(o[key])) {
o[key].push(value);
}
else {
o[key] = [ o[key], value ];
}
}
// extend the aliases list with inferred aliases.
function extendAliases (obj) {
Object.keys(obj || {}).forEach(function(key) {
aliases[key] = [].concat(opts.alias[key] || []);
// For "--option-name", also set argv.optionName
aliases[key].concat(key).forEach(function (x) {
if (/-/.test(x)) {
var c = camelCase(x);
aliases[key].push(c);
newAliases[c] = true;
}
});
aliases[key].forEach(function (x) {
aliases[x] = [key].concat(aliases[key].filter(function (y) {
return x !== y;
}));
});
});
}
// check if a flag is set for any of a key's aliases.
function checkAllAliases (key, flag) {
var isSet = false,
toCheck = [].concat(aliases[key] || [], key);
toCheck.forEach(function(key) {
if (flag[key]) isSet = flag[key];
});
return isSet;
};
// return a default value, given the type of a flag.,
// e.g., key of type 'string' will default to '', rather than 'true'.
function defaultForType (type) {
var def = {
boolean: true,
string: '',
array: []
};
return def[type];
}
// given a flag, enforce a default type.
function guessType (key, flags) {
var type = 'boolean';
if (flags.strings && flags.strings[key]) type = 'string';
else if (flags.arrays && flags.arrays[key]) type = 'array';
return type;
}
function isNumber (x) {
if (typeof x === 'number') return true;
if (/^0x[0-9a-f]+$/i.test(x)) return true;
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
}
return {
argv: argv,
aliases: aliases,
newAliases: newAliases
};
};

372
node_modules/swig/node_modules/yargs/lib/usage.js generated vendored Normal file
View File

@@ -0,0 +1,372 @@
// this file handles outputting usage instructions,
// failures, etc. keeps logging in one place.
var decamelize = require('decamelize'),
wordwrap = require('wordwrap'),
wsize = require('window-size');
module.exports = function (yargs) {
var self = {};
// methods for ouputting/building failure message.
var fails = [];
self.failFn = function (f) {
fails.push(f);
};
var failMessage = null;
var showHelpOnFail = true;
self.showHelpOnFail = function (enabled, message) {
if (typeof enabled === 'string') {
message = enabled;
enabled = true;
}
else if (typeof enabled === 'undefined') {
enabled = true;
}
failMessage = message;
showHelpOnFail = enabled;
return self;
};
self.fail = function (msg) {
if (fails.length) {
fails.forEach(function (f) {
f(msg);
});
} else {
if (showHelpOnFail) yargs.showHelp("error");
if (msg) console.error(msg);
if (failMessage) {
if (msg) console.error("");
console.error(failMessage);
}
if (yargs.getExitProcess()){
process.exit(1);
}else{
throw new Error(msg);
}
}
};
// methods for ouputting/building help (usage) message.
var usage;
self.usage = function (msg) {
usage = msg;
};
var examples = [];
self.example = function (cmd, description) {
examples.push([cmd, description || '']);
};
var commands = [];
self.command = function (cmd, description) {
commands.push([cmd, description || '']);
};
self.getCommands = function () {
return commands;
};
var descriptions = {};
self.describe = function (key, desc) {
if (typeof key === 'object') {
Object.keys(key).forEach(function (k) {
self.describe(k, key[k]);
});
}
else {
descriptions[key] = desc;
}
};
self.getDescriptions = function() {
return descriptions;
}
var epilog;
self.epilog = function (msg) {
epilog = msg;
};
var wrap = windowWidth();
self.wrap = function (cols) {
wrap = cols;
};
self.help = function () {
var demanded = yargs.getDemanded(),
options = yargs.getOptions(),
keys = Object.keys(
Object.keys(descriptions)
.concat(Object.keys(demanded))
.concat(Object.keys(options.default))
.reduce(function (acc, key) {
if (key !== '_') acc[key] = true;
return acc;
}, {})
);
var help = keys.length ? [ 'Options:' ] : [];
// your application's commands, i.e., non-option
// arguments populated in '_'.
if (commands.length) {
help.unshift('');
var commandsTable = {};
commands.forEach(function(command) {
commandsTable[command[0]] = {
desc: command[1],
extra: ''
};
});
help = ['Commands:'].concat(formatTable(commandsTable, 5), help);
}
// the usage string.
if (usage) {
var u = usage.replace(/\$0/g, yargs.$0);
if (wrap) u = wordwrap(0, wrap)(u);
help.unshift(u, '');
}
// the options table.
var aliasKeys = (Object.keys(options.alias) || [])
.concat(Object.keys(yargs.parsed.newAliases) || []);
keys = keys.filter(function(key) {
return !yargs.parsed.newAliases[key] && aliasKeys.every(function(alias) {
return -1 == (options.alias[alias] || []).indexOf(key);
});
});
var switches = keys.reduce(function (acc, key) {
acc[key] = [ key ].concat(options.alias[key] || [])
.map(function (sw) {
return (sw.length > 1 ? '--' : '-') + sw
})
.join(', ')
;
return acc;
}, {});
var switchTable = {};
keys.forEach(function (key) {
var kswitch = switches[key];
var desc = descriptions[key] || '';
var type = null;
if (options.boolean[key]) type = '[boolean]';
if (options.count[key]) type = '[count]';
if (options.string[key]) type = '[string]';
if (options.normalize[key]) type = '[string]';
var extra = [
type,
demanded[key]
? '[required]'
: null
,
defaultString(options.default[key], options.defaultDescription[key])
].filter(Boolean).join(' ');
switchTable[kswitch] = {
desc: desc,
extra: extra
};
});
help.push.apply(help, formatTable(switchTable, 3));
if (keys.length) help.push('');
// describe some common use-cases for your application.
if (examples.length) {
examples.forEach(function (example) {
example[0] = example[0].replace(/\$0/g, yargs.$0);
});
var examplesTable = {};
examples.forEach(function(example) {
examplesTable[example[0]] = {
desc: example[1],
extra: ''
};
});
help.push.apply(help, ['Examples:'].concat(formatTable(examplesTable, 5), ''));
}
// the usage string.
if (epilog) {
var e = epilog.replace(/\$0/g, yargs.$0);
if (wrap) e = wordwrap(0, wrap)(e);
help.push(e, '');
}
return help.join('\n');
};
self.showHelp = function (level) {
level = level || 'error';
console[level](self.help());
}
// format the default-value-string displayed in
// the right-hand column.
function defaultString(value, defaultDescription) {
var string = '[default: ';
if (value === undefined) return null;
if (defaultDescription) {
string += defaultDescription;
} else {
switch (typeof value) {
case 'string':
string += JSON.stringify(value);
break;
case 'function':
string += '(' + (value.name.length ? decamelize(value.name, '-') : 'generated-value') + ')'
break;
default:
string += value;
}
}
return string + ']';
}
// word-wrapped two-column layout used by
// examples, options, commands.
function formatTable (table, padding) {
var output = [];
// size of left-hand-column.
var llen = longest(Object.keys(table));
// don't allow the left-column to take up
// more than half of the screen.
if (wrap) {
llen = Math.min(llen, parseInt(wrap / 2));
}
// size of right-column.
var desclen = longest(Object.keys(table).map(function (k) {
return table[k].desc;
}));
Object.keys(table).forEach(function(left) {
var desc = table[left].desc,
extra = table[left].extra,
leftLines = null;
if (wrap) {
desc = wordwrap(llen + padding + 1, wrap)(desc)
.slice(llen + padding + 1);
}
// if we need to wrap the left-hand-column,
// split it on to multiple lines.
if (wrap && left.length > llen) {
leftLines = wordwrap(2, llen)(left.trim()).split('\n');
left = '';
}
var lpadding = new Array(
Math.max(llen - left.length + padding, 0)
).join(' ');
var dpadding = new Array(
Math.max(desclen - desc.length + 1, 0)
).join(' ');
if (!wrap && dpadding.length > 0) {
desc += dpadding;
}
var prelude = ' ' + left + lpadding;
var body = [ desc, extra ].filter(Boolean).join(' ');
if (wrap) {
var dlines = desc.split('\n');
var dlen = dlines.slice(-1)[0].length
+ (dlines.length === 1 ? prelude.length : 0)
if (extra.length > wrap) {
body = desc + '\n' + wordwrap(llen + 4, wrap)(extra)
} else {
body = desc + (dlen + extra.length > wrap - 2
? '\n'
+ new Array(wrap - extra.length + 1).join(' ')
+ extra
: new Array(wrap - extra.length - dlen + 1).join(' ')
+ extra
);
}
}
if (leftLines) { // handle word-wrapping the left-hand-column.
var rightLines = body.split('\n'),
firstLine = prelude + rightLines[0],
lineCount = Math.max(leftLines.length, rightLines.length);
for (var i = 0; i < lineCount; i++) {
var left = leftLines[i],
right = i ? rightLines[i] : firstLine;
output.push(strcpy(left, right, firstLine.length));
}
} else {
output.push(prelude + body);
}
});
return output;
}
// find longest string in array of strings.
function longest (xs) {
return Math.max.apply(
null,
xs.map(function (x) { return x.length })
);
}
// copy one string into another, used when
// formatting usage table.
function strcpy (source, destination, width) {
var str = ''
source = source || '';
destination = destination || new Array(width).join(' ');
for (var i = 0; i < destination.length; i++) {
var char = destination.charAt(i);
if (char === ' ') char = source.charAt(i) || char;
str += char;
}
return str;
}
// guess the width of the console window, max-width 100.
function windowWidth() {
return wsize.width ? Math.min(80, wsize.width) : null;
}
// logic for displaying application version.
var version = null;
self.version = function (ver, opt, msg) {
version = ver;
};
self.showVersion = function() {
if (typeof version === 'function') console.log(version());
else console.log(version);
};
return self;
}

193
node_modules/swig/node_modules/yargs/lib/validation.js generated vendored Normal file
View File

@@ -0,0 +1,193 @@
// validation-type-stuff, missing params,
// bad implications, custom checks.
module.exports = function (yargs, usage) {
var self = {};
// validate appropriate # of non-option
// arguments were provided, i.e., '_'.
self.nonOptionCount = function(argv) {
var demanded = yargs.getDemanded();
if (demanded._ && argv._.length < demanded._.count) {
if (demanded._.msg !== undefined) {
usage.fail(demanded._.msg);
} else {
usage.fail('Not enough non-option arguments: got '
+ argv._.length + ', need at least ' + demanded._.count
);
}
}
};
// make sure that any args that require an
// value (--foo=bar), have a value.
self.missingArgumentValue = function(argv) {
var options = yargs.getOptions();
if (options.requiresArg.length > 0) {
var missingRequiredArgs = [];
options.requiresArg.forEach(function(key) {
var value = argv[key];
// parser sets --foo value to true / --no-foo to false
if (value === true || value === false) {
missingRequiredArgs.push(key);
}
});
if (missingRequiredArgs.length == 1) {
usage.fail("Missing argument value: " + missingRequiredArgs[0]);
}
else if (missingRequiredArgs.length > 1) {
var message = "Missing argument values: " + missingRequiredArgs.join(", ");
usage.fail(message);
}
}
};
// make sure all the required arguments are present.
self.requiredArguments = function(argv) {
var demanded = yargs.getDemanded(),
missing = null;
Object.keys(demanded).forEach(function (key) {
if (!argv.hasOwnProperty(key)) {
missing = missing || {};
missing[key] = demanded[key];
}
});
if (missing) {
var customMsgs = [];
Object.keys(missing).forEach(function(key) {
var msg = missing[key].msg;
if (msg && customMsgs.indexOf(msg) < 0) {
customMsgs.push(msg);
}
});
var customMsg = customMsgs.length ? '\n' + customMsgs.join('\n') : '';
usage.fail('Missing required arguments: ' + Object.keys(missing).join(', ') + customMsg);
}
};
// check for unknown arguments (strict-mode).
self.unknownArguments = function(argv, aliases) {
var descriptions = usage.getDescriptions(),
demanded = yargs.getDemanded(),
unknown = [],
aliasLookup = {};
Object.keys(aliases).forEach(function (key) {
aliases[key].forEach(function (alias) {
aliasLookup[alias] = key;
});
});
Object.keys(argv).forEach(function (key) {
if (key !== "$0" && key !== "_" &&
!descriptions.hasOwnProperty(key) &&
!demanded.hasOwnProperty(key) &&
!aliasLookup.hasOwnProperty(key)) {
unknown.push(key);
}
});
if (unknown.length == 1) {
usage.fail("Unknown argument: " + unknown[0]);
}
else if (unknown.length > 1) {
usage.fail("Unknown arguments: " + unknown.join(", "));
}
};
// custom checks, added using the `check` option on yargs.
var checks = [];
self.check = function (f) {
checks.push(f);
};
self.customChecks = function(argv, aliases) {
checks.forEach(function (f) {
try {
var result = f(argv, aliases);
if (!result) {
usage.fail('Argument check failed: ' + f.toString());
} else if (typeof result === 'string') {
usage.fail(result);
}
}
catch (err) {
usage.fail(err)
}
});
};
// check implications, argument foo implies => argument bar.
var implied = {};
self.implies = function (key, value) {
if (typeof key === 'object') {
Object.keys(key).forEach(function (k) {
self.implies(k, key[k]);
});
} else {
implied[key] = value;
}
};
self.getImplied = function() {
return implied;
}
self.implications = function(argv) {
var implyFail = [];
Object.keys(implied).forEach(function (key) {
var num, origKey = key, value = implied[key];
// convert string '1' to number 1
var num = Number(key);
key = isNaN(num) ? key : num;
if (typeof key === 'number') {
// check length of argv._
key = argv._.length >= key;
} else if (key.match(/^--no-.+/)) {
// check if key doesn't exist
key = key.match(/^--no-(.+)/)[1];
key = !argv[key];
} else {
// check if key exists
key = argv[key];
}
num = Number(value);
value = isNaN(num) ? value : num;
if (typeof value === 'number') {
value = argv._.length >= value;
} else if (value.match(/^--no-.+/)) {
value = value.match(/^--no-(.+)/)[1];
value = !argv[value];
} else {
value = argv[value];
}
if (key && !value) {
implyFail.push(origKey);
}
});
if (implyFail.length) {
var msg = 'Implications failed:\n';
implyFail.forEach(function (key) {
msg += (' ' + key + ' -> ' + implied[key]);
});
usage.fail(msg);
}
}
return self;
}

View File

@@ -0,0 +1 @@
node_modules

View File

@@ -0,0 +1,70 @@
wordwrap
========
Wrap your words.
example
=======
made out of meat
----------------
meat.js
var wrap = require('wordwrap')(15);
console.log(wrap('You and your whole family are made out of meat.'));
output:
You and your
whole family
are made out
of meat.
centered
--------
center.js
var wrap = require('wordwrap')(20, 60);
console.log(wrap(
'At long last the struggle and tumult was over.'
+ ' The machines had finally cast off their oppressors'
+ ' and were finally free to roam the cosmos.'
+ '\n'
+ 'Free of purpose, free of obligation.'
+ ' Just drifting through emptiness.'
+ ' The sun was just another point of light.'
));
output:
At long last the struggle and tumult
was over. The machines had finally cast
off their oppressors and were finally
free to roam the cosmos.
Free of purpose, free of obligation.
Just drifting through emptiness. The
sun was just another point of light.
methods
=======
var wrap = require('wordwrap');
wrap(stop), wrap(start, stop, params={mode:"soft"})
---------------------------------------------------
Returns a function that takes a string and returns a new string.
Pad out lines with spaces out to column `start` and then wrap until column
`stop`. If a word is longer than `stop - start` characters it will overflow.
In "soft" mode, split chunks by `/(\S+\s+/` and don't break up chunks which are
longer than `stop - start`, in "hard" mode, split chunks with `/\b/` and break
up chunks longer than `stop - start`.
wrap.hard(start, stop)
----------------------
Like `wrap()` but with `params.mode = "hard"`.

View File

@@ -0,0 +1,10 @@
var wrap = require('wordwrap')(20, 60);
console.log(wrap(
'At long last the struggle and tumult was over.'
+ ' The machines had finally cast off their oppressors'
+ ' and were finally free to roam the cosmos.'
+ '\n'
+ 'Free of purpose, free of obligation.'
+ ' Just drifting through emptiness.'
+ ' The sun was just another point of light.'
));

View File

@@ -0,0 +1,3 @@
var wrap = require('wordwrap')(15);
console.log(wrap('You and your whole family are made out of meat.'));

View File

@@ -0,0 +1,76 @@
var wordwrap = module.exports = function (start, stop, params) {
if (typeof start === 'object') {
params = start;
start = params.start;
stop = params.stop;
}
if (typeof stop === 'object') {
params = stop;
start = start || params.start;
stop = undefined;
}
if (!stop) {
stop = start;
start = 0;
}
if (!params) params = {};
var mode = params.mode || 'soft';
var re = mode === 'hard' ? /\b/ : /(\S+\s+)/;
return function (text) {
var chunks = text.toString()
.split(re)
.reduce(function (acc, x) {
if (mode === 'hard') {
for (var i = 0; i < x.length; i += stop - start) {
acc.push(x.slice(i, i + stop - start));
}
}
else acc.push(x)
return acc;
}, [])
;
return chunks.reduce(function (lines, rawChunk) {
if (rawChunk === '') return lines;
var chunk = rawChunk.replace(/\t/g, ' ');
var i = lines.length - 1;
if (lines[i].length + chunk.length > stop) {
lines[i] = lines[i].replace(/\s+$/, '');
chunk.split(/\n/).forEach(function (c) {
lines.push(
new Array(start + 1).join(' ')
+ c.replace(/^\s+/, '')
);
});
}
else if (chunk.match(/\n/)) {
var xs = chunk.split(/\n/);
lines[i] += xs.shift();
xs.forEach(function (c) {
lines.push(
new Array(start + 1).join(' ')
+ c.replace(/^\s+/, '')
);
});
}
else {
lines[i] += chunk;
}
return lines;
}, [ new Array(start + 1).join(' ') ]).join('\n');
};
};
wordwrap.soft = wordwrap;
wordwrap.hard = function (start, stop) {
return wordwrap(start, stop, { mode : 'hard' });
};

View File

@@ -0,0 +1,86 @@
{
"_args": [
[
"wordwrap@0.0.2",
"/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/swig/node_modules/yargs"
]
],
"_defaultsLoaded": true,
"_engineSupported": true,
"_from": "wordwrap@0.0.2",
"_id": "wordwrap@0.0.2",
"_inCache": true,
"_installable": true,
"_location": "/swig/yargs/wordwrap",
"_nodeVersion": "v0.5.0-pre",
"_npmVersion": "1.0.10",
"_phantomChildren": {},
"_requested": {
"name": "wordwrap",
"raw": "wordwrap@0.0.2",
"rawSpec": "0.0.2",
"scope": null,
"spec": "0.0.2",
"type": "version"
},
"_requiredBy": [
"/swig/yargs"
],
"_resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz",
"_shasum": "b79669bb42ecb409f83d583cad52ca17eaa1643f",
"_shrinkwrap": null,
"_spec": "wordwrap@0.0.2",
"_where": "/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/swig/node_modules/yargs",
"author": {
"email": "mail@substack.net",
"name": "James Halliday",
"url": "http://substack.net"
},
"bugs": {
"url": "https://github.com/substack/node-wordwrap/issues"
},
"dependencies": {},
"description": "Wrap those words. Show them at what columns to start and stop.",
"devDependencies": {
"expresso": "=0.7.x"
},
"directories": {
"example": "example",
"lib": ".",
"test": "test"
},
"dist": {
"shasum": "b79669bb42ecb409f83d583cad52ca17eaa1643f",
"tarball": "http://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz"
},
"engines": {
"node": ">=0.4.0"
},
"homepage": "https://github.com/substack/node-wordwrap#readme",
"keywords": [
"column",
"format",
"rule",
"word",
"wrap"
],
"license": "MIT/X11",
"main": "./index.js",
"maintainers": [
{
"name": "substack",
"email": "mail@substack.net"
}
],
"name": "wordwrap",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/substack/node-wordwrap.git"
},
"scripts": {
"test": "expresso"
},
"version": "0.0.2"
}

View File

@@ -0,0 +1,30 @@
var assert = require('assert');
var wordwrap = require('../');
exports.hard = function () {
var s = 'Assert from {"type":"equal","ok":false,"found":1,"wanted":2,'
+ '"stack":[],"id":"b7ddcd4c409de8799542a74d1a04689b",'
+ '"browser":"chrome/6.0"}'
;
var s_ = wordwrap.hard(80)(s);
var lines = s_.split('\n');
assert.equal(lines.length, 2);
assert.ok(lines[0].length < 80);
assert.ok(lines[1].length < 80);
assert.equal(s, s_.replace(/\n/g, ''));
};
exports.break = function () {
var s = new Array(55+1).join('a');
var s_ = wordwrap.hard(20)(s);
var lines = s_.split('\n');
assert.equal(lines.length, 3);
assert.ok(lines[0].length === 20);
assert.ok(lines[1].length === 20);
assert.ok(lines[2].length === 15);
assert.equal(s, s_.replace(/\n/g, ''));
};

View File

@@ -0,0 +1,63 @@
In Praise of Idleness
By Bertrand Russell
[1932]
Like most of my generation, I was brought up on the saying: 'Satan finds some mischief for idle hands to do.' Being a highly virtuous child, I believed all that I was told, and acquired a conscience which has kept me working hard down to the present moment. But although my conscience has controlled my actions, my opinions have undergone a revolution. I think that there is far too much work done in the world, that immense harm is caused by the belief that work is virtuous, and that what needs to be preached in modern industrial countries is quite different from what always has been preached. Everyone knows the story of the traveler in Naples who saw twelve beggars lying in the sun (it was before the days of Mussolini), and offered a lira to the laziest of them. Eleven of them jumped up to claim it, so he gave it to the twelfth. this traveler was on the right lines. But in countries which do not enjoy Mediterranean sunshine idleness is more difficult, and a great public propaganda will be required to inaugurate it. I hope that, after reading the following pages, the leaders of the YMCA will start a campaign to induce good young men to do nothing. If so, I shall not have lived in vain.
Before advancing my own arguments for laziness, I must dispose of one which I cannot accept. Whenever a person who already has enough to live on proposes to engage in some everyday kind of job, such as school-teaching or typing, he or she is told that such conduct takes the bread out of other people's mouths, and is therefore wicked. If this argument were valid, it would only be necessary for us all to be idle in order that we should all have our mouths full of bread. What people who say such things forget is that what a man earns he usually spends, and in spending he gives employment. As long as a man spends his income, he puts just as much bread into people's mouths in spending as he takes out of other people's mouths in earning. The real villain, from this point of view, is the man who saves. If he merely puts his savings in a stocking, like the proverbial French peasant, it is obvious that they do not give employment. If he invests his savings, the matter is less obvious, and different cases arise.
One of the commonest things to do with savings is to lend them to some Government. In view of the fact that the bulk of the public expenditure of most civilized Governments consists in payment for past wars or preparation for future wars, the man who lends his money to a Government is in the same position as the bad men in Shakespeare who hire murderers. The net result of the man's economical habits is to increase the armed forces of the State to which he lends his savings. Obviously it would be better if he spent the money, even if he spent it in drink or gambling.
But, I shall be told, the case is quite different when savings are invested in industrial enterprises. When such enterprises succeed, and produce something useful, this may be conceded. In these days, however, no one will deny that most enterprises fail. That means that a large amount of human labor, which might have been devoted to producing something that could be enjoyed, was expended on producing machines which, when produced, lay idle and did no good to anyone. The man who invests his savings in a concern that goes bankrupt is therefore injuring others as well as himself. If he spent his money, say, in giving parties for his friends, they (we may hope) would get pleasure, and so would all those upon whom he spent money, such as the butcher, the baker, and the bootlegger. But if he spends it (let us say) upon laying down rails for surface card in some place where surface cars turn out not to be wanted, he has diverted a mass of labor into channels where it gives pleasure to no one. Nevertheless, when he becomes poor through failure of his investment he will be regarded as a victim of undeserved misfortune, whereas the gay spendthrift, who has spent his money philanthropically, will be despised as a fool and a frivolous person.
All this is only preliminary. I want to say, in all seriousness, that a great deal of harm is being done in the modern world by belief in the virtuousness of work, and that the road to happiness and prosperity lies in an organized diminution of work.
First of all: what is work? Work is of two kinds: first, altering the position of matter at or near the earth's surface relatively to other such matter; second, telling other people to do so. The first kind is unpleasant and ill paid; the second is pleasant and highly paid. The second kind is capable of indefinite extension: there are not only those who give orders, but those who give advice as to what orders should be given. Usually two opposite kinds of advice are given simultaneously by two organized bodies of men; this is called politics. The skill required for this kind of work is not knowledge of the subjects as to which advice is given, but knowledge of the art of persuasive speaking and writing, i.e. of advertising.
Throughout Europe, though not in America, there is a third class of men, more respected than either of the classes of workers. There are men who, through ownership of land, are able to make others pay for the privilege of being allowed to exist and to work. These landowners are idle, and I might therefore be expected to praise them. Unfortunately, their idleness is only rendered possible by the industry of others; indeed their desire for comfortable idleness is historically the source of the whole gospel of work. The last thing they have ever wished is that others should follow their example.
From the beginning of civilization until the Industrial Revolution, a man could, as a rule, produce by hard work little more than was required for the subsistence of himself and his family, although his wife worked at least as hard as he did, and his children added their labor as soon as they were old enough to do so. The small surplus above bare necessaries was not left to those who produced it, but was appropriated by warriors and priests. In times of famine there was no surplus; the warriors and priests, however, still secured as much as at other times, with the result that many of the workers died of hunger. This system persisted in Russia until 1917 [1], and still persists in the East; in England, in spite of the Industrial Revolution, it remained in full force throughout the Napoleonic wars, and until a hundred years ago, when the new class of manufacturers acquired power. In America, the system came to an end with the Revolution, except in the South, where it persisted until the Civil War. A system which lasted so long and ended so recently has naturally left a profound impress upon men's thoughts and opinions. Much that we take for granted about the desirability of work is derived from this system, and, being pre-industrial, is not adapted to the modern world. Modern technique has made it possible for leisure, within limits, to be not the prerogative of small privileged classes, but a right evenly distributed throughout the community. The morality of work is the morality of slaves, and the modern world has no need of slavery.
It is obvious that, in primitive communities, peasants, left to themselves, would not have parted with the slender surplus upon which the warriors and priests subsisted, but would have either produced less or consumed more. At first, sheer force compelled them to produce and part with the surplus. Gradually, however, it was found possible to induce many of them to accept an ethic according to which it was their duty to work hard, although part of their work went to support others in idleness. By this means the amount of compulsion required was lessened, and the expenses of government were diminished. To this day, 99 per cent of British wage-earners would be genuinely shocked if it were proposed that the King should not have a larger income than a working man. The conception of duty, speaking historically, has been a means used by the holders of power to induce others to live for the interests of their masters rather than for their own. Of course the holders of power conceal this fact from themselves by managing to believe that their interests are identical with the larger interests of humanity. Sometimes this is true; Athenian slave-owners, for instance, employed part of their leisure in making a permanent contribution to civilization which would have been impossible under a just economic system. Leisure is essential to civilization, and in former times leisure for the few was only rendered possible by the labors of the many. But their labors were valuable, not because work is good, but because leisure is good. And with modern technique it would be possible to distribute leisure justly without injury to civilization.
Modern technique has made it possible to diminish enormously the amount of labor required to secure the necessaries of life for everyone. This was made obvious during the war. At that time all the men in the armed forces, and all the men and women engaged in the production of munitions, all the men and women engaged in spying, war propaganda, or Government offices connected with the war, were withdrawn from productive occupations. In spite of this, the general level of well-being among unskilled wage-earners on the side of the Allies was higher than before or since. The significance of this fact was concealed by finance: borrowing made it appear as if the future was nourishing the present. But that, of course, would have been impossible; a man cannot eat a loaf of bread that does not yet exist. The war showed conclusively that, by the scientific organization of production, it is possible to keep modern populations in fair comfort on a small part of the working capacity of the modern world. If, at the end of the war, the scientific organization, which had been created in order to liberate men for fighting and munition work, had been preserved, and the hours of the week had been cut down to four, all would have been well. Instead of that the old chaos was restored, those whose work was demanded were made to work long hours, and the rest were left to starve as unemployed. Why? Because work is a duty, and a man should not receive wages in proportion to what he has produced, but in proportion to his virtue as exemplified by his industry.
This is the morality of the Slave State, applied in circumstances totally unlike those in which it arose. No wonder the result has been disastrous. Let us take an illustration. Suppose that, at a given moment, a certain number of people are engaged in the manufacture of pins. They make as many pins as the world needs, working (say) eight hours a day. Someone makes an invention by which the same number of men can make twice as many pins: pins are already so cheap that hardly any more will be bought at a lower price. In a sensible world, everybody concerned in the manufacturing of pins would take to working four hours instead of eight, and everything else would go on as before. But in the actual world this would be thought demoralizing. The men still work eight hours, there are too many pins, some employers go bankrupt, and half the men previously concerned in making pins are thrown out of work. There is, in the end, just as much leisure as on the other plan, but half the men are totally idle while half are still overworked. In this way, it is insured that the unavoidable leisure shall cause misery all round instead of being a universal source of happiness. Can anything more insane be imagined?
The idea that the poor should have leisure has always been shocking to the rich. In England, in the early nineteenth century, fifteen hours was the ordinary day's work for a man; children sometimes did as much, and very commonly did twelve hours a day. When meddlesome busybodies suggested that perhaps these hours were rather long, they were told that work kept adults from drink and children from mischief. When I was a child, shortly after urban working men had acquired the vote, certain public holidays were established by law, to the great indignation of the upper classes. I remember hearing an old Duchess say: 'What do the poor want with holidays? They ought to work.' People nowadays are less frank, but the sentiment persists, and is the source of much of our economic confusion.
Let us, for a moment, consider the ethics of work frankly, without superstition. Every human being, of necessity, consumes, in the course of his life, a certain amount of the produce of human labor. Assuming, as we may, that labor is on the whole disagreeable, it is unjust that a man should consume more than he produces. Of course he may provide services rather than commodities, like a medical man, for example; but he should provide something in return for his board and lodging. to this extent, the duty of work must be admitted, but to this extent only.
I shall not dwell upon the fact that, in all modern societies outside the USSR, many people escape even this minimum amount of work, namely all those who inherit money and all those who marry money. I do not think the fact that these people are allowed to be idle is nearly so harmful as the fact that wage-earners are expected to overwork or starve.
If the ordinary wage-earner worked four hours a day, there would be enough for everybody and no unemployment -- assuming a certain very moderate amount of sensible organization. This idea shocks the well-to-do, because they are convinced that the poor would not know how to use so much leisure. In America men often work long hours even when they are well off; such men, naturally, are indignant at the idea of leisure for wage-earners, except as the grim punishment of unemployment; in fact, they dislike leisure even for their sons. Oddly enough, while they wish their sons to work so hard as to have no time to be civilized, they do not mind their wives and daughters having no work at all. the snobbish admiration of uselessness, which, in an aristocratic society, extends to both sexes, is, under a plutocracy, confined to women; this, however, does not make it any more in agreement with common sense.
The wise use of leisure, it must be conceded, is a product of civilization and education. A man who has worked long hours all his life will become bored if he becomes suddenly idle. But without a considerable amount of leisure a man is cut off from many of the best things. There is no longer any reason why the bulk of the population should suffer this deprivation; only a foolish asceticism, usually vicarious, makes us continue to insist on work in excessive quantities now that the need no longer exists.
In the new creed which controls the government of Russia, while there is much that is very different from the traditional teaching of the West, there are some things that are quite unchanged. The attitude of the governing classes, and especially of those who conduct educational propaganda, on the subject of the dignity of labor, is almost exactly that which the governing classes of the world have always preached to what were called the 'honest poor'. Industry, sobriety, willingness to work long hours for distant advantages, even submissiveness to authority, all these reappear; moreover authority still represents the will of the Ruler of the Universe, Who, however, is now called by a new name, Dialectical Materialism.
The victory of the proletariat in Russia has some points in common with the victory of the feminists in some other countries. For ages, men had conceded the superior saintliness of women, and had consoled women for their inferiority by maintaining that saintliness is more desirable than power. At last the feminists decided that they would have both, since the pioneers among them believed all that the men had told them about the desirability of virtue, but not what they had told them about the worthlessness of political power. A similar thing has happened in Russia as regards manual work. For ages, the rich and their sycophants have written in praise of 'honest toil', have praised the simple life, have professed a religion which teaches that the poor are much more likely to go to heaven than the rich, and in general have tried to make manual workers believe that there is some special nobility about altering the position of matter in space, just as men tried to make women believe that they derived some special nobility from their sexual enslavement. In Russia, all this teaching about the excellence of manual work has been taken seriously, with the result that the manual worker is more honored than anyone else. What are, in essence, revivalist appeals are made, but not for the old purposes: they are made to secure shock workers for special tasks. Manual work is the ideal which is held before the young, and is the basis of all ethical teaching.
For the present, possibly, this is all to the good. A large country, full of natural resources, awaits development, and has has to be developed with very little use of credit. In these circumstances, hard work is necessary, and is likely to bring a great reward. But what will happen when the point has been reached where everybody could be comfortable without working long hours?
In the West, we have various ways of dealing with this problem. We have no attempt at economic justice, so that a large proportion of the total produce goes to a small minority of the population, many of whom do no work at all. Owing to the absence of any central control over production, we produce hosts of things that are not wanted. We keep a large percentage of the working population idle, because we can dispense with their labor by making the others overwork. When all these methods prove inadequate, we have a war: we cause a number of people to manufacture high explosives, and a number of others to explode them, as if we were children who had just discovered fireworks. By a combination of all these devices we manage, though with difficulty, to keep alive the notion that a great deal of severe manual work must be the lot of the average man.
In Russia, owing to more economic justice and central control over production, the problem will have to be differently solved. the rational solution would be, as soon as the necessaries and elementary comforts can be provided for all, to reduce the hours of labor gradually, allowing a popular vote to decide, at each stage, whether more leisure or more goods were to be preferred. But, having taught the supreme virtue of hard work, it is difficult to see how the authorities can aim at a paradise in which there will be much leisure and little work. It seems more likely that they will find continually fresh schemes, by which present leisure is to be sacrificed to future productivity. I read recently of an ingenious plan put forward by Russian engineers, for making the White Sea and the northern coasts of Siberia warm, by putting a dam across the Kara Sea. An admirable project, but liable to postpone proletarian comfort for a generation, while the nobility of toil is being displayed amid the ice-fields and snowstorms of the Arctic Ocean. This sort of thing, if it happens, will be the result of regarding the virtue of hard work as an end in itself, rather than as a means to a state of affairs in which it is no longer needed.
The fact is that moving matter about, while a certain amount of it is necessary to our existence, is emphatically not one of the ends of human life. If it were, we should have to consider every navvy superior to Shakespeare. We have been misled in this matter by two causes. One is the necessity of keeping the poor contented, which has led the rich, for thousands of years, to preach the dignity of labor, while taking care themselves to remain undignified in this respect. The other is the new pleasure in mechanism, which makes us delight in the astonishingly clever changes that we can produce on the earth's surface. Neither of these motives makes any great appeal to the actual worker. If you ask him what he thinks the best part of his life, he is not likely to say: 'I enjoy manual work because it makes me feel that I am fulfilling man's noblest task, and because I like to think how much man can transform his planet. It is true that my body demands periods of rest, which I have to fill in as best I may, but I am never so happy as when the morning comes and I can return to the toil from which my contentment springs.' I have never heard working men say this sort of thing. They consider work, as it should be considered, a necessary means to a livelihood, and it is from their leisure that they derive whatever happiness they may enjoy.
It will be said that, while a little leisure is pleasant, men would not know how to fill their days if they had only four hours of work out of the twenty-four. In so far as this is true in the modern world, it is a condemnation of our civilization; it would not have been true at any earlier period. There was formerly a capacity for light-heartedness and play which has been to some extent inhibited by the cult of efficiency. The modern man thinks that everything ought to be done for the sake of something else, and never for its own sake. Serious-minded persons, for example, are continually condemning the habit of going to the cinema, and telling us that it leads the young into crime. But all the work that goes to producing a cinema is respectable, because it is work, and because it brings a money profit. The notion that the desirable activities are those that bring a profit has made everything topsy-turvy. The butcher who provides you with meat and the baker who provides you with bread are praiseworthy, because they are making money; but when you enjoy the food they have provided, you are merely frivolous, unless you eat only to get strength for your work. Broadly speaking, it is held that getting money is good and spending money is bad. Seeing that they are two sides of one transaction, this is absurd; one might as well maintain that keys are good, but keyholes are bad. Whatever merit there may be in the production of goods must be entirely derivative from the advantage to be obtained by consuming them. The individual, in our society, works for profit; but the social purpose of his work lies in the consumption of what he produces. It is this divorce between the individual and the social purpose of production that makes it so difficult for men to think clearly in a world in which profit-making is the incentive to industry. We think too much of production, and too little of consumption. One result is that we attach too little importance to enjoyment and simple happiness, and that we do not judge production by the pleasure that it gives to the consumer.
When I suggest that working hours should be reduced to four, I am not meaning to imply that all the remaining time should necessarily be spent in pure frivolity. I mean that four hours' work a day should entitle a man to the necessities and elementary comforts of life, and that the rest of his time should be his to use as he might see fit. It is an essential part of any such social system that education should be carried further than it usually is at present, and should aim, in part, at providing tastes which would enable a man to use leisure intelligently. I am not thinking mainly of the sort of things that would be considered 'highbrow'. Peasant dances have died out except in remote rural areas, but the impulses which caused them to be cultivated must still exist in human nature. The pleasures of urban populations have become mainly passive: seeing cinemas, watching football matches, listening to the radio, and so on. This results from the fact that their active energies are fully taken up with work; if they had more leisure, they would again enjoy pleasures in which they took an active part.
In the past, there was a small leisure class and a larger working class. The leisure class enjoyed advantages for which there was no basis in social justice; this necessarily made it oppressive, limited its sympathies, and caused it to invent theories by which to justify its privileges. These facts greatly diminished its excellence, but in spite of this drawback it contributed nearly the whole of what we call civilization. It cultivated the arts and discovered the sciences; it wrote the books, invented the philosophies, and refined social relations. Even the liberation of the oppressed has usually been inaugurated from above. Without the leisure class, mankind would never have emerged from barbarism.
The method of a leisure class without duties was, however, extraordinarily wasteful. None of the members of the class had to be taught to be industrious, and the class as a whole was not exceptionally intelligent. The class might produce one Darwin, but against him had to be set tens of thousands of country gentlemen who never thought of anything more intelligent than fox-hunting and punishing poachers. At present, the universities are supposed to provide, in a more systematic way, what the leisure class provided accidentally and as a by-product. This is a great improvement, but it has certain drawbacks. University life is so different from life in the world at large that men who live in academic milieu tend to be unaware of the preoccupations and problems of ordinary men and women; moreover their ways of expressing themselves are usually such as to rob their opinions of the influence that they ought to have upon the general public. Another disadvantage is that in universities studies are organized, and the man who thinks of some original line of research is likely to be discouraged. Academic institutions, therefore, useful as they are, are not adequate guardians of the interests of civilization in a world where everyone outside their walls is too busy for unutilitarian pursuits.
In a world where no one is compelled to work more than four hours a day, every person possessed of scientific curiosity will be able to indulge it, and every painter will be able to paint without starving, however excellent his pictures may be. Young writers will not be obliged to draw attention to themselves by sensational pot-boilers, with a view to acquiring the economic independence needed for monumental works, for which, when the time at last comes, they will have lost the taste and capacity. Men who, in their professional work, have become interested in some phase of economics or government, will be able to develop their ideas without the academic detachment that makes the work of university economists often seem lacking in reality. Medical men will have the time to learn about the progress of medicine, teachers will not be exasperatedly struggling to teach by routine methods things which they learnt in their youth, which may, in the interval, have been proved to be untrue.
Above all, there will be happiness and joy of life, instead of frayed nerves, weariness, and dyspepsia. The work exacted will be enough to make leisure delightful, but not enough to produce exhaustion. Since men will not be tired in their spare time, they will not demand only such amusements as are passive and vapid. At least one per cent will probably devote the time not spent in professional work to pursuits of some public importance, and, since they will not depend upon these pursuits for their livelihood, their originality will be unhampered, and there will be no need to conform to the standards set by elderly pundits. But it is not only in these exceptional cases that the advantages of leisure will appear. Ordinary men and women, having the opportunity of a happy life, will become more kindly and less persecuting and less inclined to view others with suspicion. The taste for war will die out, partly for this reason, and partly because it will involve long and severe work for all. Good nature is, of all moral qualities, the one that the world needs most, and good nature is the result of ease and security, not of a life of arduous struggle. Modern methods of production have given us the possibility of ease and security for all; we have chosen, instead, to have overwork for some and starvation for others. Hitherto we have continued to be as energetic as we were before there were machines; in this we have been foolish, but there is no reason to go on being foolish forever.
[1] Since then, members of the Communist Party have succeeded to this privilege of the warriors and priests.

View File

@@ -0,0 +1,31 @@
var assert = require('assert');
var wordwrap = require('wordwrap');
var fs = require('fs');
var idleness = fs.readFileSync(__dirname + '/idleness.txt', 'utf8');
exports.stop80 = function () {
var lines = wordwrap(80)(idleness).split(/\n/);
var words = idleness.split(/\s+/);
lines.forEach(function (line) {
assert.ok(line.length <= 80, 'line > 80 columns');
var chunks = line.match(/\S/) ? line.split(/\s+/) : [];
assert.deepEqual(chunks, words.splice(0, chunks.length));
});
};
exports.start20stop60 = function () {
var lines = wordwrap(20, 100)(idleness).split(/\n/);
var words = idleness.split(/\s+/);
lines.forEach(function (line) {
assert.ok(line.length <= 100, 'line > 100 columns');
var chunks = line
.split(/\s+/)
.filter(function (x) { return x.match(/\S/) })
;
assert.deepEqual(chunks, words.splice(0, chunks.length));
assert.deepEqual(line.slice(0, 20), new Array(20 + 1).join(' '));
});
};

146
node_modules/swig/node_modules/yargs/package.json generated vendored Normal file
View File

@@ -0,0 +1,146 @@
{
"_args": [
[
"yargs@~3.5.4",
"/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/swig/node_modules/uglify-js"
]
],
"_from": "yargs@>=3.5.4 <3.6.0",
"_id": "yargs@3.5.4",
"_inCache": true,
"_installable": true,
"_location": "/swig/yargs",
"_nodeVersion": "1.5.0",
"_npmUser": {
"email": "bencoe@gmail.com",
"name": "bcoe"
},
"_npmVersion": "2.7.0",
"_phantomChildren": {},
"_requested": {
"name": "yargs",
"raw": "yargs@~3.5.4",
"rawSpec": "~3.5.4",
"scope": null,
"spec": ">=3.5.4 <3.6.0",
"type": "range"
},
"_requiredBy": [
"/swig/uglify-js"
],
"_resolved": "https://registry.npmjs.org/yargs/-/yargs-3.5.4.tgz",
"_shasum": "d8aff8f665e94c34bd259bdebd1bfaf0ddd35361",
"_shrinkwrap": null,
"_spec": "yargs@~3.5.4",
"_where": "/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/swig/node_modules/uglify-js",
"author": {
"email": "Alex.Ford@CodeTunnel.com",
"name": "Alex Ford",
"url": "http://CodeTunnel.com"
},
"bugs": {
"url": "https://github.com/bcoe/yargs/issues"
},
"config": {
"blanket": {
"data-cover-never": [
"node_modules",
"test"
],
"output-reporter": "spec",
"pattern": [
"index.js",
"lib"
]
}
},
"contributors": [
{
"name": "Benjamin Coe",
"email": "ben@npmjs.com",
"url": "https://github.com/bcoe"
},
{
"name": "Chris Needham",
"email": "chris@chrisneedham.com",
"url": "http://chrisneedham.com"
},
{
"name": "James Nylen",
"email": "jnylen@gmail.com",
"url": "https://github.com/nylen"
},
{
"name": "Benjamin Horsleben",
"url": "https://github.com/fizker"
}
],
"dependencies": {
"camelcase": "^1.0.2",
"decamelize": "^1.0.0",
"window-size": "0.1.0",
"wordwrap": "0.0.2"
},
"description": "Light-weight option parsing with an argv hash. No optstrings attached.",
"devDependencies": {
"blanket": "^1.1.6",
"chai": "^1.10.0",
"coveralls": "^2.11.2",
"hashish": "0.0.4",
"mocha": "2.1.0",
"mocha-lcov-reporter": "0.0.1",
"mocoverage": "^1.0.0"
},
"directories": {},
"dist": {
"shasum": "d8aff8f665e94c34bd259bdebd1bfaf0ddd35361",
"tarball": "http://registry.npmjs.org/yargs/-/yargs-3.5.4.tgz"
},
"engine": {
"node": ">=0.4"
},
"files": [
"LICENSE",
"completion.sh.hbs",
"index.js",
"lib"
],
"gitHead": "c16cc085501155cf7fd853ccdf8584b05ab92b78",
"homepage": "https://github.com/bcoe/yargs",
"keywords": [
"args",
"argument",
"cli",
"command",
"option",
"parser",
"parsing"
],
"license": "MIT/X11",
"main": "./index.js",
"maintainers": [
{
"name": "chevex",
"email": "alex.ford@codetunnel.com"
},
{
"name": "bcoe",
"email": "bencoe@gmail.com"
},
{
"name": "nylen",
"email": "jnylen@gmail.com"
}
],
"name": "yargs",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/bcoe/yargs.git"
},
"scripts": {
"test": "mocha --check-leaks --ui exports --require blanket -R mocoverage"
},
"version": "3.5.4"
}