-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmydxcli.js
48 lines (42 loc) · 1.54 KB
/
mydxcli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var nopt = require("nopt"),
path = require("path"),
metadataoperator=require('./lib/XmlCreator'),
knownOpts = { "username" : [String],
"getProfile":[String,Boolean],
"getPermissionSet":[String,Boolean],
"help":[Boolean],
"directory":[String],
"ignore":[String]
},
shortHands = { "u" : ["--username"],
"gP" :["--getProfile"],
"gPs":["--getPermissionSet"],
"h":["--help"],
"d":["--directory"],
"ig":["--ignore"]
},
helper="\n-u or --username\t<username or alias name>\n\n-gP or --getProfile\t<Profilename> if not mentioned all profile will be taken by default.for mutiple profiles enter them seperate by comma(,)";
mydxcli = module.exports = function () {
this.basedirectory = process.env.PWD;
if (!this.basedirectory) {
this.basedirectory = process.cwd();
}
return this;
}
mydxcli.prototype.respondtocli=function(successcallback,errorcallback){
var parent=this;
optionparser = nopt(knownOpts, shortHands, process.argv, 2);
console.log(optionparser,optionparser.help,optionparser.username);
if(optionparser.help){
successcallback(helper);
}
else if(!optionparser.username){
errorcallback("Mention the operation you want . Type --help for details ,usernamenot found");
}
else if (optionparser.getProfile || optionparser.getPermissionSet){
metadataoperator(optionparser.username,optionparser,successcallback,optionparser.directory?path.resolve(optionparser.directory):null);
}
else{
errorcallback("Mention the operation you want . Type --help for details");
}
}