Module: command-lines Synopsis: The commands provided by the environment Author: Andy Armstrong Copyright: Original Code is Copyright (c) 1995-2004 Functional Objects, Inc. All rights reserved. License: Functional Objects Library Public License Version 1.0 Dual-license: GNU Lesser General Public License Warranty: Distributed WITHOUT WARRANTY OF ANY KIND /// Operating system properties define class () end class ; define command-property directory => (summary: "Working directory", documentation: "The current working directory.", type: ) end command-property directory; define method show-property (context :: , property :: ) => () message(context, "Directory: %s", as(, working-directory())) end method show-property; define method set-property (context :: , property :: , locator :: , #key save?) => () working-directory() := locator end method set-property; /// Change directory command define class () constant slot %directory :: false-or() = #f, init-keyword: directory:; end class ; define command-line cd => (summary: "changes the current working directory", documentation: "Changes the current working directory.") optional directory :: = "the chosen directory"; end command-line cd; define method do-execute-command (context :: , command :: ) => () let directory = command.%directory; if (directory) context-named-property(context, #"directory") := directory else show-named-property(context, #"directory") end end method do-execute-command; /// OS command define class () constant slot %command :: , required-init-keyword: command:; end class ; define command-line os => (summary: "execute an operating system command", documentation: "Execute an operating system command.") argument command :: = "the OS command to execute"; end command-line os; define method do-execute-command (context :: , command :: ) => () let os-command = command.%command; let result = run-application (os-command, under-shell?: #t, inherit-console?: #t, activate?: #f, outputter: method (text :: , #key end: stop) message(context, "%s", copy-sequence(text, end: stop)) end); unless (result == 0) command-error("Operation failed with status code %d", result) end end method do-execute-command; /// Operating system commands define command-group system (summary: "operating system commands", documentation: "Operating system level commands.") property directory; command cd; command os; end command-group system;