diff --git a/js/ArgParser.js b/js/ArgParser.js index f3cfae735..b1d354359 100755 --- a/js/ArgParser.js +++ b/js/ArgParser.js @@ -1,3 +1,5 @@ +(function(){ + /* Parse a space-separated string of name:value parameters. Values can be quoted with single quotes, double quotes, double square brackets, or double curly braces. @@ -94,3 +96,5 @@ ArgParser.prototype.getValuesByName = function(n,defaultValue) { }; exports.ArgParser = ArgParser; + +})(); diff --git a/js/FileRetriever.js b/js/FileRetriever.js index 2b11f3658..ce4d7570c 100644 --- a/js/FileRetriever.js +++ b/js/FileRetriever.js @@ -1,3 +1,5 @@ +(function(){ + /* FileRetriever can asynchronously retrieve files from HTTP URLs or the local file system */ @@ -77,3 +79,5 @@ FileRetriever.retrieveFile = function(filepath,contextPath,callback) { callback(err,result); }); }; + +})(); diff --git a/js/Recipe.js b/js/Recipe.js index bd0d14cee..9ce8020d9 100755 --- a/js/Recipe.js +++ b/js/Recipe.js @@ -1,3 +1,5 @@ +(function(){ + /* Recipe processing is in four parts: @@ -333,3 +335,4 @@ Recipe.prototype.cookRss = function() exports.Recipe = Recipe; +})(); diff --git a/js/TextProcessors.js b/js/TextProcessors.js index 6dace7fc2..a8b04abc4 100644 --- a/js/TextProcessors.js +++ b/js/TextProcessors.js @@ -1,3 +1,5 @@ +(function(){ + /*jslint node: true */ "use strict"; @@ -24,3 +26,5 @@ TextProcessors.prototype.parse = function(type,text) { }; exports.TextProcessors = TextProcessors; + +})(); diff --git a/js/Tiddler.js b/js/Tiddler.js index e831a132d..f36ef046a 100755 --- a/js/Tiddler.js +++ b/js/Tiddler.js @@ -1,3 +1,5 @@ +(function(){ + /* Tiddlers are an immutable dictionary of name:value pairs called fields. Values can be a string, an array @@ -105,3 +107,5 @@ Tiddler.specialTiddlerFieldParsers = { }; exports.Tiddler = Tiddler; + +})(); diff --git a/js/TiddlerConverters.js b/js/TiddlerConverters.js index 6d8d6af19..9cbb429f6 100644 --- a/js/TiddlerConverters.js +++ b/js/TiddlerConverters.js @@ -1,3 +1,5 @@ +(function(){ + /*jslint node: true */ "use strict"; @@ -44,3 +46,5 @@ TiddlerConverters.prototype.deserialize = function(type,text,srcFields) { }; exports.TiddlerConverters = TiddlerConverters; + +})(); diff --git a/js/TiddlerInput.js b/js/TiddlerInput.js index 768354802..eaae9924a 100755 --- a/js/TiddlerInput.js +++ b/js/TiddlerInput.js @@ -1,3 +1,5 @@ +(function(){ + /* Functions concerned with parsing representations of tiddlers */ @@ -162,3 +164,5 @@ tiddlerInput.register = function(tiddlerConverters) { tiddlerConverters.registerDeserializer(".json","application/json",inputTiddlerJSON); tiddlerConverters.registerDeserializer(".tiddlywiki","application/x-tiddlywiki",inputTiddlyWiki); }; + +})(); diff --git a/js/TiddlerOutput.js b/js/TiddlerOutput.js index 6ca5a1b0d..aae93c74e 100755 --- a/js/TiddlerOutput.js +++ b/js/TiddlerOutput.js @@ -1,3 +1,5 @@ +(function(){ + /* Functions concerned with parsing representations of tiddlers */ @@ -104,3 +106,5 @@ tiddlerOutput.register = function(tiddlerConverters) { tiddlerConverters.registerSerializer(".tid","application/x-tiddler",outputTiddler); tiddlerConverters.registerSerializer(".tiddler","application/x-tiddler-html-div",outputTiddlerDiv); }; + +})(); diff --git a/js/Utils.js b/js/Utils.js index 8743ab2a3..b68407043 100755 --- a/js/Utils.js +++ b/js/Utils.js @@ -1,3 +1,5 @@ +(function(){ + /* Various static utility functions. @@ -17,7 +19,7 @@ utils.deepCopy = function(v) { for(t=0; t csw.args.max) { - throw "Command line switch --" + s.switchName + " should have a maximum of " + csw.args.max + " arguments"; - } - csw.handler(s.args,function (err) { - if(err) { - throw err; - } - process.nextTick(processNextSwitch); - }); - } -}; - -process.nextTick(processNextSwitch); - /* Each command line switch is represented by a function that takes a string array of arguments and a callback to be invoked when the switch processing has completed. The only argument to the callback is an error code, or null @@ -247,3 +228,25 @@ var commandLineSwitches = { } }; +var processNextSwitch = function() { + if(currSwitch < switches.length) { + var s = switches[currSwitch++], + csw = commandLineSwitches[s.switchName]; + if(s.args.length < csw.args.min) { + throw "Command line switch --" + s.switchName + " should have a minimum of " + csw.args.min + " arguments"; + } + if(s.args.length > csw.args.max) { + throw "Command line switch --" + s.switchName + " should have a maximum of " + csw.args.max + " arguments"; + } + csw.handler(s.args,function (err) { + if(err) { + throw err; + } + process.nextTick(processNextSwitch); + }); + } +}; + +process.nextTick(processNextSwitch); + +})(); diff --git a/wikitest.js b/wikitest.js index 3c405b274..834810c8c 100644 --- a/wikitest.js +++ b/wikitest.js @@ -1,3 +1,5 @@ +(function(){ + /* Wikifier test rig @@ -61,3 +63,5 @@ for(t=0; t