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, procName] ← ExtractParts[inputName];
localSwitches ← CommandUtil.GetSwitches[switches, defaultSwitches];
IF outputName = NIL THEN outputName ← rootName;
outputName ← CommandUtil.SetExtension[outputName, "cl"];
Initialize[];
ListerUtil.SetTypescript[cmd.out];
ListerOps.ListProc[
input: rootName,
proc: procName,
output: outputName,
options: [
full: localSwitches['h] OR localSwitches['o],
stripped: localSwitches['s],
radix: IF localSwitches['h] THEN hex ELSE octal]
! UNWIND => Finalize[]];
Finalize[];
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;