Initialize: PROC = INLINE {RepeatCommand[cmd.out]};
Finalize: PROC = INLINE {};
[inputName, commandArgs, results, switches] ←
CommandUtil.Parse[cmd.commandLine
! CommandUtil.Failed => {GO TO badSyntax}];
IF inputName = NIL AND switches = NIL THEN EXIT; -- done listing
cmd.out.PutRope["\nCommand: "];
CommandUtil.Echo[
d: cmd.out, operator: inputName, argList: commandArgs,
resultList: results, switches: switches];
IF inputName = NIL THEN GO TO globalSwitches;
SELECT CommandUtil.ListLength[results]
FROM
0 => outputName ← NIL;
1 => outputName ← CommandUtil.GetNth[list: results, n: 0];
ENDCASE => GO TO badSemantics;
rootName ← CommandUtil.GetRootName[inputName];
localSwitches ← CommandUtil.GetSwitches[switches, defaultSwitches];
IF localSwitches['v] THEN outputName ← NIL
ELSE {
IF outputName =
NIL
THEN outputName ← rootName;
outputName ← CommandUtil.SetExtension[outputName, "bl"]};
BEGIN
ENABLE UNWIND => {Finalize[]};
Initialize[];
SELECT
TRUE
FROM
localSwitches['v] => ListerOps.ListVersion[rootName];
localSwitches['s] => ListerOps.ListStamps[rootName, outputName];
localSwitches['f] => ListerOps.ListFiles[rootName, outputName];
localSwitches['r] => ListerOps.ListRTBcd[rootName, outputName, localSwitches['o]];
localSwitches['b] => ListerOps.ListBcd[rootName, outputName, localSwitches['l]];
ENDCASE;
Finalize[];
END;
IF cmd.in.UserAbort[] THEN EXIT;
EXITS
globalSwitches => {
defaultSwitches ← CommandUtil.GetSwitches[switches, defaultSwitches];
switches ← NIL; results ← NIL};
badSemantics => {
results ← NIL;
cmd.out.PutRope["\n -- Illegal command"]}};
REPEAT
badSyntax => {cmd.out.PutRope["-- Illegal syntax"]};
ENDLOOP;