/*\ title: $:/core/modules/commands/dump.js type: application/javascript module-type: command Dump command for inspecting TiddlyWiki internals \*/ (function(){ /*jshint node: true, browser: true */ /*global $tw: false */ "use strict"; exports.info = { name: "dump", synchronous: true }; var Command = function(params,commander) { this.params = params; this.commander = commander; this.output = commander.streams.output; }; Command.prototype.execute = function() { if(this.params.length < 1) { return "Too few parameters for dump command"; } var subcommand = this.subcommands[this.params[0]]; if(subcommand) { return subcommand.call(this); } else { return "Unknown subcommand (" + this.params[0] + ") for dump command"; } }; Command.prototype.subcommands = {}; Command.prototype.subcommands.tiddler = function() { if(this.params.length < 2) { return "Too few parameters for dump tiddler command"; } var tiddler = this.commander.wiki.getTiddler(this.params[1]); if(!tiddler) { return "No such tiddler as '" + this.params[1] + "'"; } this.output.write("Tiddler '" + this.params[1] + "' contains these fields:\n"); for(var t in tiddler.fields) { this.output.write(" " + t + ": " + tiddler.getFieldString(t) + "\n"); } return null; // No error }; Command.prototype.subcommands.tiddlers = function() { var tiddlers = this.commander.wiki.getTiddlers(); this.output.write("Wiki contains these tiddlers:\n"); for(var t=0; t