mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Added command line switch to load tiddlers
This commit is contained in:
parent
5c97f7a66b
commit
dc8871f9a2
@ -38,12 +38,10 @@ As of 2nd December 2011, cook.js can now build a fully functional TiddlyWiki fro
|
|||||||
|
|
||||||
## Plans for new command line interface
|
## Plans for new command line interface
|
||||||
|
|
||||||
The idea is to join `cook.js`, `ginsu.js` and `server.js` into a single command line tool, provisionally called `tiddlywiki.js`. This would be used as follows:
|
There is now an experimental new command line interface that combines `cook.js`, `ginsu.js` and `server.js`, provisionally called `tiddlywiki.js`. It is used as follows:
|
||||||
|
|
||||||
node tiddlywiki.js <options>
|
node tiddlywiki.js <options>
|
||||||
|
|
||||||
An interesting potential goal is that the same `tiddlywiki.js` file could be used in the browser as on the server side.
|
|
||||||
|
|
||||||
The command line options are processed in sequential order from left to right. Processing pauses during long operations, like loading a recipe file and all the subrecipes and tiddlers that it references. The following options are available:
|
The command line options are processed in sequential order from left to right. Processing pauses during long operations, like loading a recipe file and all the subrecipes and tiddlers that it references. The following options are available:
|
||||||
|
|
||||||
--recipe <filepath> # Loads a specfied `.recipe` file
|
--recipe <filepath> # Loads a specfied `.recipe` file
|
||||||
|
@ -11,6 +11,7 @@ var WikiStore = require("./js/WikiStore.js").WikiStore,
|
|||||||
Tiddler = require("./js/Tiddler.js").Tiddler,
|
Tiddler = require("./js/Tiddler.js").Tiddler,
|
||||||
tiddlyWikiInput = require("./js/TiddlyWikiInput.js"),
|
tiddlyWikiInput = require("./js/TiddlyWikiInput.js"),
|
||||||
tiddlerOutput = require("./js/TiddlerOutput.js"),
|
tiddlerOutput = require("./js/TiddlerOutput.js"),
|
||||||
|
tiddlerInput = require("./js/TiddlerInput.js"),
|
||||||
util = require("util"),
|
util = require("util"),
|
||||||
fs = require("fs"),
|
fs = require("fs"),
|
||||||
path = require("path"),
|
path = require("path"),
|
||||||
@ -86,10 +87,28 @@ var commandLineSwitches = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
dumpstore: {
|
||||||
|
args: {min: 0, max: 0},
|
||||||
|
handler: function(args,callback) {
|
||||||
|
console.log("Store is:\n%s",util.inspect(store,false,10));
|
||||||
|
process.nextTick(function() {callback(null);});
|
||||||
|
}
|
||||||
|
},
|
||||||
load: {
|
load: {
|
||||||
args: {min: 1, max: 1},
|
args: {min: 1, max: 1},
|
||||||
handler: function(args,callback) {
|
handler: function(args,callback) {
|
||||||
process.nextTick(function() {callback(null);});
|
fs.readFile(args[0],"utf8",function(err,data) {
|
||||||
|
if(err) {
|
||||||
|
callback(err);
|
||||||
|
} else {
|
||||||
|
var fields = {title: args[0]};
|
||||||
|
var tiddlers = tiddlerInput.parseTiddlerFile(data,path.extname(args[0]),fields);
|
||||||
|
for(var t=0; t<tiddlers.length; t++) {
|
||||||
|
store.addTiddler(new Tiddler(tiddlers[t]));
|
||||||
|
}
|
||||||
|
callback(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
savewiki: {
|
savewiki: {
|
||||||
|
Loading…
Reference in New Issue
Block a user