cloudcms-cli
Version:
Cloud CMS Command-Line client
92 lines (83 loc) • 3.03 kB
JavaScript
var helper = require("../../../helper");
var AbstractCommand = require("../../abstract");
class ValidateBranchCommand extends AbstractCommand
{
constructor()
{
super({
"group": "admin",
"name": "validate-branch",
"description": "Runs validation checks against a branch and reports any findings",
"schema": {
"properties": [{
"name": "repositoryId",
"type": "string",
"description": "Enter the repository ID",
"required": true,
"args": ["repository", "r"]
}, {
"name": "branchId",
"type": "string",
"description": "Enter the branch ID",
"required": true,
"args": ["branch", "b"]
}, {
"name": "nodeList",
"type": "boolean",
"description": "Hand back a list of affected node IDs",
"required": false,
"args": ["nodeList"]
}, {
"name": "repair",
"type": "boolean",
"description": "Automatically repairs any affected nodes by refreshing them",
"required": false,
"args": ["repair"]
}, {
"name": "typeQNames",
"type": "string",
"description": "Type QNames to validate instances of",
"required": false,
"args": ["typeQName", "type"]
}, {
"name": "username",
"type": "string",
"description": "Admin username",
"required": true,
"args": ["username", "u"]
}, {
"name": "password",
"type": "string",
"description": "Admin password",
"required": true,
"hidden": true,
"args": ["password", "p"]
}]
}
});
}
handle(options, callback)
{
var config = {};
if (options.nodeList) {
config.nodeList = true;
}
if (options.repair) {
config.repair = true;
}
if (options.typeQNames)
{
var typeQNames = options.typeQNames;
if (typeof(typeQNames) === "string") {
typeQNames = [typeQNames];
}
config.typeQNames = typeQNames;
}
// call workhorse function
helper.validateBranch(options.repositoryId, options.branchId, options.username, options.password, config, function(err) {
console.log(""); // this forces stdout to flush
callback(err);
});
}
}
module.exports = ValidateBranchCommand;