Module: console-environment Synopsis: The command line version of 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 define abstract class () constant slot %echo-input? :: = #f, init-keyword: echo-input?:; constant slot %profile-commands? :: = #f, init-keyword: profile-commands?:; constant slot %personal-root :: false-or() = #f, init-keyword: personal-root:; constant slot %system-root :: false-or() = #f, init-keyword: system-root:; constant slot %project :: false-or() = #f, init-keyword: project:; constant slot %help? :: = #f, init-keyword: help?:; constant slot %logo? :: = #t, init-keyword: logo?:; constant slot %debugger? :: = #f, init-keyword: debugger?:; constant slot %import? :: = #f, init-keyword: import?:; constant slot %build? :: = #f, init-keyword: build?:; constant slot %compile? :: = #f, init-keyword: compile?:; constant slot %link? :: = #f, init-keyword: link?:; constant slot %subprojects? :: = #t, init-keyword: subprojects?:; constant slot %clean? :: = #f, init-keyword: clean?:; constant slot %release? :: = #f, init-keyword: release?:; constant slot %build-script :: false-or() = #f, init-keyword: build-script:; constant slot %target :: false-or() = #f, init-keyword: target:; constant slot %force? :: = #f, init-keyword: force?:; constant slot %unify? :: = #f, init-keyword: unify?:; constant slot %not-recursive? :: = #f, init-keyword: not-recursive?:; constant slot %save? :: = #t, init-keyword: save?:; constant slot %link-dll? :: = #f, init-keyword: link-dll?:; constant slot %link-exe? :: = #f, init-keyword: link-exe?:; constant slot %gnu-exports? :: = #f, init-keyword: gnu-exports?:; constant slot %debug-info :: = #"full", init-keyword: debug-info:; constant slot %messages :: false-or() = #f, init-keyword: messages:; /*---*** fill this in later. constant slot %harp? :: = #f, init-keyword: harp?:; constant slot %assemble? = #f, init-keyword: assemble?:; constant slot %dfm? :: = #f, init-keyword: dfm?:; constant slot %exports? :: = #f, init-keyword: exports?:; let gc? = #f; let mode = #f; let libraries :: = make(); */ end class ; //---*** We need to implement these... ignore(%gnu-exports?, %debug-info, %messages); define method execute-main-command (context :: , command :: ) => (status-code :: ) local method run (class :: subclass(), #rest arguments) => () let command = apply(make, class, server: context, arguments); execute-command(command) end method run; let filename = command.%project; if (command.%import?) run(, file: filename) else run(, file: filename) end; let dw-options? = command.%link-dll? | command.%link-exe?; let bwild? = command.%build? | dw-options?; if (build? | coomand.%compile?) run(, clean?: command.%clean?, save?: command.%save?, link?: #f, release?: command.%release?, subprojects: command.%subprojects? & ~command.%not-recursive?) end; if (build? | command.%link?) let target = command.%target | case command.%link-dll? => #"dll"; command.%link-exe? => #"executable"; end; run(, build-script: command.%build-script, target: target, force?: command.%force? | command.%clean?, subprojects: command.%subprojects? & ~command.%not-recursive?, unify?: command.%unify?) end; $success-exit-code; end method execute-main-command; define method execute-main-loop (context :: , command :: ) => (status-code :: ) let echo-input? = command.%echo-input?; let profile-commands? = command.%profile-commands?; command-line-loop (context.context-server, debugger?: command.%debugger?, echo-input?: echo-input?, profile-commands?: profile-commands?); $success-exit-code; end method execute-main-loop; define method do-execute-command (context :: , command :: ) => (status-code :: ) block (return) let handler () = method (condition :: , next-handler :: ) if (command.%debugger?) next-handler() else display-condition(context, condition); message(context, "Exiting with return code %d", $error-exit-code); return($error-exit-code) end end; local method run (class :: subclass(), #rest arguments) => () let command = apply(make, class, server: context, arguments); execute-command(command) end method run; if (command.%help?) let command-line = select (command by instance?) => $main-command-line; otherwise => $internal-main-command-line; end; let filename = as(, application-filename()); run(, command: command-line, title: as-uppercase(locator-base(filename))); $success-exit-code else command.%logo? & message(context, dylan-banner()); let personal-root = command.%personal-root; let system-root = command.%system-root; personal-root & set-named-property(context, #"personal-root", personal-root); system-root & set-named-property(context, #"system-root", system-root); case command.%project => execute-main-command(context, command); otherwise => execute-main-loop(context, command); end end end end method do-execute-command;