/* Copyright 2014-2017 Research Foundation State University of New York */
/* This file is part of QUB Online. */
/* QUB Online is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* QUB Online is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* You should have received a copy of the GNU General Public License, */
/* named LICENSE.txt, in the QUB Online program directory. If not, see */
/* . */
const requirejs = require('requirejs');
requirejs.config({
//Pass the top-level main.js/index.js require
//function to requirejs so that node modules
//are loaded relative to the top-level JS file.
nodeRequire: require,
// paths: {
// "qubx": "../js/qubx"
// },
map: {
"*": {
"jquery" : "jquery_adapter"
}
}
});
requirejs(['commander', 'modeldb'], function(commander, modeldb) {
commander
.version('0.0.1')
.option("-n, --name ", "Full name")
.option("-a, --about ", "Description (organization, etc)")
.option("-e, --email ", "Email address")
.option("-s, --can-save", "Has permission to save models")
.option("-v, --can-self-invite", "Has permission to issue own-account invitations")
.option("-i, --can-invite", "Has permission to invite new users")
.option("-m, --can-admin", "Has permission to administer users")
.option("-x, --expires-hours ", "Invitation expires this many hours in the future")
.option("-u, --uses-remain ", "Maximum uses of this invite (0 for infinite)")
.parse(process.argv);
if ( commander.name && commander.email ) {
new modeldb.Session()
.inviteTrusted({personName: commander.name,
personAbout: commander.about,
personEmail: commander.email,
personCanSave: commander.canSave,
personCanSelfInvite: commander.canSelfInvite,
personCanInvite: commander.canInvite,
personCanAdmin: commander.canAdmin
},
commander.expiresHours?parseInt(commander.expiresHours):740,
commander.usesRemain?parseInt(commander.usesRemain):0)
.then(function(secret) {
console.log("Invitation sent:",secret);
process.exit();
})
.catch(function(err) {
console.log(err);
process.exit();
});
} else {
commander.outputHelp();
}
});