<<>> <> <> <> <> <> <<>> DIRECTORY GlobalRunDefaults, Commander, IO, Rope; GlobalRunDefaultsImpl: CEDAR MONITOR IMPORTS Commander, IO, Rope EXPORTS GlobalRunDefaults ~ { globalDefaultSwitches: Rope.ROPE ¬ "-"; <> GetGlobalRunDefaults: PUBLIC ENTRY PROCEDURE [] RETURNS [Rope.ROPE] ~ { RETURN [globalDefaultSwitches]; }; SetGlobalRunDefaults: PUBLIC ENTRY PROCEDURE [defaults: Rope.ROPE] RETURNS [old: Rope.ROPE] ~ { old ¬ globalDefaultSwitches; globalDefaultSwitches ¬ defaults; RETURN [old: old]; }; RunGlobalDefaultsCmd: Commander.CommandProc ~ { { -- extra scope to contain EXITS. cmds: IO.STREAM ~ IO.RIS[cmd.commandLine]; switches: Rope.ROPE ~ GetCmdToken[cmds ! QuotedStringError => { msg ¬ "Mismatched quotes"; GO TO Failure; }]; IF Rope.Size[switches] > 0 AND Rope.Fetch[switches, 0] = '- THEN { [] ¬ SetGlobalRunDefaults[defaults: switches]; }; EXITS Failure => { result ¬ $Failure; }; }; msg ¬ Rope.Concat["Global default switches for Run are ", GetGlobalRunDefaults[]]; RETURN [result: result, msg: msg]; }; QuotedStringError: ERROR ~ CODE; CmdTokenBreak: PROCEDURE [char: CHAR] RETURNS [IO.CharClass] = { IF char = '" THEN RETURN [break]; IF char = ' OR char = '\t OR char = ', OR char = '\l OR char = '\r THEN RETURN [sepr]; RETURN [other]; }; GetCmdToken: PROCEDURE [stream: IO.STREAM] RETURNS [token: Rope.ROPE ¬ NIL] ~ { token ¬ IO.GetTokenRope[stream, CmdTokenBreak ! IO.EndOfStream => CONTINUE].token; IF Rope.Equal[token, "\""] THEN { ref: REF; IO.Backup[self: stream, char: '"]; ref ¬ IO.GetRefAny[stream ! IO.Error, IO.EndOfStream => ERROR QuotedStringError]; WITH ref SELECT FROM rope: Rope.ROPE => token ¬ rope; ENDCASE => ERROR QuotedStringError; }; RETURN [token: token]; }; RegisterWithCommander: PROCEDURE [] RETURNS [] ~ { Commander.Register[ key: "RunGlobalDefaultSwitches", proc: RunGlobalDefaultsCmd, doc: "Set global default switches for the Run command"]; RETURN; }; RegisterWithCommander[]; }.