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

Added support for a different (preferred) method of property format

specification ("<prop>=<format>"). The "-fmt <format>" option syntax is
still supported.
Fixed a bunch of typos and update the "docs" in the comment header.
parent 30345d62
No related branches found
No related tags found
No related merge requests found
...@@ -24,17 +24,21 @@ ...@@ -24,17 +24,21 @@
// If you specify property names on the command-line, only those configuration // If you specify property names on the command-line, only those configuration
// properties will be included in the output. You may also follow a property // properties will be included in the output. You may also follow a property
// name with the -fmt <format> or -upr options to specify a printf-style // name with =<format> to specify a printf-style format string to use when
// format string or to convert the value to uppercase before printing. a -lwr // outputting the property value. You can also *follow* property names with the
// (lowercase) option is also available. // -upr or -lwr options to convert the property value to uppercase or lowercase
// respectively.
// As an example, to generate a RAID/FILEBONE.NA/FILEGATE.ZXX format listing: // As an example, to generate a RAID/FILEBONE.NA/FILEGATE.ZXX format listing:
// jsexec fileareas.js code -upr -fmt "Area %-16s 0 !" description // jsexec fileareas.js code="Area %-16s 0 !" -upr description
// When using the -json or -json_space command-line options, the output will // For a list of available properties, see this:
// be formatted as JSON objects and certain options (e.g. -delim, -hdr, -quote) // http://synchro.net/docs/jsobjs.html#file_area.lib_list.dir_list_properties
// will have no effect on the output. For example, to output a pretty-printed
// JSON represenation of all file areas: // When using the -json or command-line option, the output will be formatted
// as JSON objects and certain options (e.g. -delim, -hdr, -quote) will have no
// effect on the output. For example, to output a pretty-printed JSON
// representation of all file areas:
// jsexec fileareas.js -json 4 > fileareas.json // jsexec fileareas.js -json 4 > fileareas.json
// NOTE: // NOTE:
...@@ -66,30 +70,38 @@ var lib = []; ...@@ -66,30 +70,38 @@ var lib = [];
for(var i = 0; i < argc; i++) { for(var i = 0; i < argc; i++) {
if(argv[i].charAt(0) != '-') { if(argv[i].charAt(0) != '-') {
props.push(argv[i]); var arg = argv[i];
var eq = arg.indexOf('=');
if(eq >= 0) {
if(eq < 1)
throw("invalid format: " + arg);
arg = arg.slice(0, eq);
fmt[arg] = argv[i].slice(eq + 1);
}
props.push(arg);
continue; continue;
} }
switch(argv[i]) { switch(argv[i]) {
case '-lib': case '-lib':
lib.push(argv[++i].toLowerCase()); lib.push(argv[++i].toLowerCase());
continue; continue;
case '-fmt': case '-fmt': // Alternate syntax to <prop>=<fmt>
if(props.length > 0) if(props.length > 0)
fmt[props[props.length - 1]] = argv[++i]; fmt[props[props.length - 1]] = argv[++i];
else else
throw(argv[i] + " must follow a property specificatoin"); throw(argv[i] + " must follow a property specification");
continue; continue;
case '-upr': case '-upr':
if(props.length > 0) if(props.length > 0)
upr[props[props.length - 1]] = true; upr[props[props.length - 1]] = true;
else else
throw(argv[i] + " must follow a property specificatoin"); throw(argv[i] + " must follow a property specification");
continue; continue;
case '-lwr': case '-lwr':
if(props.length > 0) if(props.length > 0)
lwr[props[props.length - 1]] = true; lwr[props[props.length - 1]] = true;
else else
throw(argv[i] + " must follow a property specificatoin"); throw(argv[i] + " must follow a property specification");
continue; continue;
case '-delim': case '-delim':
delim = argv[++i]; delim = argv[++i];
...@@ -104,7 +116,7 @@ for(var i = 0; i < argc; i++) { ...@@ -104,7 +116,7 @@ for(var i = 0; i < argc; i++) {
default: default:
var arg = argv[i].slice(1); var arg = argv[i].slice(1);
if(options[arg] === undefined) { if(options[arg] === undefined) {
writeln("usage: fileareas.js [[-lib <name>] [...]] [[-option] [...]] [[[prop] [-fmt <format>] [-upr | -lwr]] [...]]"); writeln("usage: fileareas.js [[-lib <name>] [...]] [[-option] [...]] [[[prop][=<format> [-upr | -lwr]] [...]]");
writeln("options:"); writeln("options:");
writeln(format("\t%-12s <default>", "<option>")); writeln(format("\t%-12s <default>", "<option>"));
for(var o in options) for(var o in options)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment