<> <> <> <> <> <> DIRECTORY IO USING [STREAM], List USING [AList], Rope USING [ROPE]; Commander: CEDAR DEFINITIONS = BEGIN OPEN IO, List, Rope; CommandProc: TYPE = PROC [cmd: Handle] RETURNS [result: REF _ NIL, msg: ROPE _ NIL]; <> <> <<>> Register: PROC [key: ROPE, proc: CommandProc _ NIL, doc: ROPE _ NIL, clientData: REF _ NIL, interpreted: BOOL _ TRUE]; <> Handle: TYPE = REF CommandObject; CommandObject: TYPE = RECORD [ in, out, err: STREAM _ NIL, <> commandLine: ROPE, <> command: ROPE _ NIL, <> propertyList: AList _ NIL, <> procData: CommandProcHandle _ NIL <> ]; CommandProcHandle: TYPE = REF CommandProcObject; CommandProcObject: TYPE = RECORD [ proc: CommandProc _ NIL, <<... is the procedure to invoke in order to perform the command.>> doc: ROPE _ NIL, <<... is a short blurb about what the command does.>> clientData: REF ANY _ NIL, <<... is passed to the command when it is invoked.>> interpreted: BOOL _ TRUE <<... controls how the command line is to be interpreted. FALSE means to do no processing, since the command itself has funny syntax. TRUE means to do I/O redirection, use semicolon separators and other processing.>> ]; Enumerate: PROC [EnumerateAction] RETURNS [key: ROPE, procData: CommandProcHandle]; EnumerateAction: TYPE = PROC [key: ROPE, procData: CommandProcHandle] RETURNS [stop: BOOL _ FALSE]; <<... calls the EnumerateAction with the key and registered procedure data for all registered commands. It will stop early if the EnumerateAction returns TRUE. Commands are not enumerated in any particular order.>> Lookup: PROC [key: ROPE] RETURNS [procData: CommandProcHandle]; <<... will look up the command and return the associated CommandProcHandle (NIL if no such command is registered). Case of keys does not matter. As in Register, if no directory part is mentioned, the current working directory will be prepended to the key.>> <<>> PrependWorkingDir: PROC [key: ROPE] RETURNS [ROPE]; <<... tests for a directory specification in the key ('[ or '/ in the first character). If there is one (or key = NIL), then returns key. Otherwise, prepends the working directory for the current process to the key and returns the result.>> <> <<>> PutProperty: PUBLIC PROC [key: REF ANY, val: REF ANY, aList: AList] RETURNS [AList]; <<... is like List.PutAssoc, except that it works correctly if the key is a ROPE.>> <<>> GetProperty: PROC [key: REF ANY, aList: AList] RETURNS [val: REF ANY]; <<... is like List.Assoc, except that it works correctly if the key is a ROPE.>> END.