Skip to content
Snippets Groups Projects
Commit e611b31b authored by rswindell's avatar rswindell
Browse files

Allow specific items (e.g. subs, dirs, xtrns, events, editors) to be

selected/included with the -inc=<code> option or excluded with the
-exc=<code> option.
Fixed a problem where some item types did not have a 'code' property
(this is a difficiency in the JS object model that will be fixed in the
future - but a work-around is to just use the associative-array 'index'
value if the 'code' property does not exist).
parent c1c465b0
No related branches found
No related tags found
No related merge requests found
......@@ -29,8 +29,10 @@ var popts = {
};
var props = [];
var propfmt = {}; // printf-style format string
var exclude = [];
var propex = []; // properties to exclude
var grp = [];
var include = []; // items to include
var exclude = []; // items to exclude
var cfgtype;
var cfgtypes = {
'msg-grps': msg_area.grp,
......@@ -52,6 +54,7 @@ function usage(msg)
}
writeln("usage: exportcfg.js <cfg-type>");
writeln("\t[[-grp=<msg_area.grp.name | file_area.lib.name | xtrn_area.sec.code>] [...]]");
writeln("\t[[-inc=<internal_code> | -exc=<internal_code>] [...]]");
writeln("\t[-<option>[=<value>] [...]]");
writeln("\t[[[property][=<printf-format> [-upper | -lower | -under]] [...]]");
writeln("\t[[-ex=<property>] [...]]");
......@@ -99,8 +102,19 @@ for(var i = 0; i < argc; i++) {
while(arg.charAt(0) == '-')
arg = arg.slice(1);
switch(arg) {
case 'inc': // include item (by code)
if(value === undefined)
value = argv[++i];
include.push(value.toLowerCase());
continue;
case 'exc': // exclude item (by code)
if(value === undefined)
value = argv[++i];
exclude.push(value.toLowerCase());
continue;
case 'lib':
case 'grp':
case 'sec':
if(value === undefined)
value = argv[++i];
grp.push(value.toLowerCase());
......@@ -108,7 +122,7 @@ for(var i = 0; i < argc; i++) {
case 'ex': // exclude property
if(value === undefined)
value = argv[++i];
exclude.push(value);
propex.push(value);
continue;
case '?':
case 'help':
......@@ -194,12 +208,21 @@ for(var i in cfglist) {
break;
}
}
if(include.length && include.indexOf(i) < 0)
continue;
if(exclude.length && exclude.indexOf(i) >= 0)
continue;
var obj = {};
if(props.length == 0)
if(props.length == 0) {
obj = item; //JSON.parse(JSON.stringify(item));
if(obj.code === undefined)
obj.code = i;
}
else {
for(var f in props) {
var value = item[props[f]];
if(value === undefined && props[f] == 'code')
value = i;
if(typeof value == 'string') {
if(popts.under[props[f]])
value = value.replace(' ', '_');
......@@ -212,8 +235,8 @@ for(var i in cfglist) {
}
}
// Remove excluded properties
for(var e in exclude)
delete obj[exclude[e]];
for(var e in propex)
delete obj[propex[e]];
for(var p in obj) {
if(typeof obj[p] == 'object')
delete obj[p];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment