1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-05 23:10:28 +00:00
TiddlyWiki5/plugins/tiddlywiki/multiwikiserver/modules/commands/mws-create-bag.js

48 lines
934 B
JavaScript
Raw Normal View History

2024-07-05 17:40:59 +00:00
/*\
title: $:/plugins/tiddlywiki/multiwikiserver/commands/mws-create-bag.js
type: application/javascript
module-type: command
Command to load archive of recipes, bags and tiddlers from a directory
--mws-create-bag <name> <description>
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
name: "mws-create-bag",
synchronous: true
};
var Command = function(params,commander,callback) {
this.params = params;
this.commander = commander;
this.callback = callback;
};
Command.prototype.execute = function() {
var self = this;
// Check parameters
if(this.params.length < 1) {
return "Missing bag name";
}
var bagName = this.params[0],
bagDescription = this.params[1] || bagName;
// Create bag
var result = $tw.mws.store.createBag(bagName,bagDescription);
if(result) {
return result.message;
} else {
return null;
}
};
exports.Command = Command;
})();