mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 12:07:19 +00:00
Add help command
This commit is contained in:
parent
2ed8df0d1f
commit
cadeb9654c
41
core/modules/commands/help.js
Normal file
41
core/modules/commands/help.js
Normal file
@ -0,0 +1,41 @@
|
||||
/*\
|
||||
title: $:/core/modules/commands/help.js
|
||||
type: application/javascript
|
||||
module-type: command
|
||||
|
||||
Help command
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jshint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
exports.info = {
|
||||
name: "help",
|
||||
synchronous: true
|
||||
};
|
||||
|
||||
var Command = function(params,commander) {
|
||||
this.params = params;
|
||||
this.commander = commander;
|
||||
};
|
||||
|
||||
Command.prototype.execute = function() {
|
||||
var subhelp = this.params[0] || "default",
|
||||
helpBase = "$:/language/Help/",
|
||||
text;
|
||||
if(!this.commander.wiki.getTiddler(helpBase + subhelp)) {
|
||||
subhelp = "notfound";
|
||||
}
|
||||
// Wikify the help as formatted text (ie block elements generate newlines)
|
||||
text = this.commander.wiki.renderTiddler("text/plain-formatted",helpBase + subhelp);
|
||||
// Remove any leading linebreaks
|
||||
text = text.replace(/^(\r?\n)*/g,"");
|
||||
this.commander.streams.output.write(text);
|
||||
};
|
||||
|
||||
exports.Command = Command;
|
||||
|
||||
})();
|
Loading…
Reference in New Issue
Block a user