Skip to content
Snippets Groups Projects
Commit d06825b3 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Make --help work and copy the option parsing logic from filelist.js

parent 3d04f9c1
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -12,26 +12,6 @@ const default_excludes = [ ...@@ -12,26 +12,6 @@ const default_excludes = [
"SFFILES.BBS" "SFFILES.BBS"
]; ];
if(argv.indexOf("-help") >= 0 || argv.indexOf("-?") >= 0) {
writeln("usage: [-options] [dir-code] [listfile]");
writeln("options:");
writeln(" -all add files in all libraries/directories (implies -auto)");
writeln(" -lib=<name> add files in all directories of specified library (implies -auto)");
writeln(" -from=<name> specify uploader's user name (may require quotes)");
writeln(" -ex=<filename> add to excluded filename list");
writeln(" (default: " + default_excludes.join(',') + ")");
writeln(" -diz always extract/use description in archive");
writeln(" -update update existing file entries (default is to skip them)");
writeln(" -date[=fmt] include today's date in description");
writeln(" -fdate[=fmt] include file's date in description");
writeln(" -adate[=fmt] include newest archived file date in description");
writeln(" (fmt = optional strftime date/time format string)");
writeln(" -delete delete list after import");
writeln(" -v increase verbosity of output");
writeln(" -debug enable debug output");
exit(0);
}
function datestr(t) function datestr(t)
{ {
if(date_fmt) if(date_fmt)
...@@ -62,12 +42,34 @@ var verbosity = 0; ...@@ -62,12 +42,34 @@ var verbosity = 0;
for(var i = 0; i < argc; i++) { for(var i = 0; i < argc; i++) {
var arg = argv[i]; var arg = argv[i];
if(arg[0] == '-') { if(arg[0] == '-') {
if(arg.indexOf("-ex=") == 0) { var opt = arg;
exclude.push(arg.slice(4).toUpperCase()); while(opt[0] == '-')
opt = opt.slice(1);
if(opt == '?' || opt.toLowerCase() == "help") {
writeln("usage: [-options] [dir-code] [listfile]");
writeln("options:");
writeln(" -all add files in all libraries/directories (implies -auto)");
writeln(" -lib=<name> add files in all directories of specified library (implies -auto)");
writeln(" -from=<name> specify uploader's user name (may require quotes)");
writeln(" -ex=<filename> add to excluded filename list");
writeln(" (default: " + default_excludes.join(',') + ")");
writeln(" -diz always extract/use description in archive");
writeln(" -update update existing file entries (default is to skip them)");
writeln(" -date[=fmt] include today's date in description");
writeln(" -fdate[=fmt] include file's date in description");
writeln(" -adate[=fmt] include newest archived file date in description");
writeln(" (fmt = optional strftime date/time format string)");
writeln(" -delete delete list after import");
writeln(" -v increase verbosity of output");
writeln(" -debug enable debug output");
exit(0);
}
if(opt.indexOf("ex=") == 0) {
exclude.push(opt.slice(3).toUpperCase());
continue; continue;
} }
if(arg.indexOf("-lib=") == 0) { if(opt.indexOf("lib=") == 0) {
var lib = arg.slice(5); var lib = opt.slice(4);
if(!file_area.lib[lib]) { if(!file_area.lib[lib]) {
alert("Library not found: " + lib); alert("Library not found: " + lib);
exit(1); exit(1);
...@@ -77,38 +79,38 @@ for(var i = 0; i < argc; i++) { ...@@ -77,38 +79,38 @@ for(var i = 0; i < argc; i++) {
options.auto = true; options.auto = true;
continue; continue;
} }
if(arg.indexOf("-from=") == 0) { if(opt.indexOf("from=") == 0) {
uploader = arg.slice(6); uploader = opt.slice(5);
continue; continue;
} }
if(arg.indexOf("-date=") == 0) { if(opt.indexOf("date=") == 0) {
date_fmt = arg.slice(6); date_fmt = opt.slice(5);
options.date = true; options.date = true;
continue; continue;
} }
if(arg.indexOf("-fdate=") == 0) { if(opt.indexOf("fdate=") == 0) {
date_fmt = arg.slice(7); date_fmt = opt.slice(6);
options.fdate = true; options.fdate = true;
continue; continue;
} }
if(arg.indexOf("-adate=") == 0) { if(opt.indexOf("adate=") == 0) {
date_fmt = arg.slice(7); date_fmt = opt.slice(6);
options.adate = true; options.adate = true;
continue; continue;
} }
if(arg == '-' || arg == '-all') { if(opt == "all") {
for(var dir in file_area.dir) for(var dir in file_area.dir)
dir_list.push(dir); dir_list.push(dir);
options.auto = true; options.auto = true;
continue; continue;
} }
if(arg[1] == 'v') { if(opt[0] == 'v') {
var j = 1; var j = 0;
while(arg[j++] == 'v') while(opt[j++] == 'v')
verbosity++; verbosity++;
continue; continue;
} }
options[arg.slice(1)] = true; options[opt] = true;
} else { } else {
if(!dir_list.length) if(!dir_list.length)
dir_list.push(arg); dir_list.push(arg);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment