/[cmucl]/src/code/commandline.lisp
ViewVC logotype

Diff of /src/code/commandline.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.17 by rtoy, Tue Jan 6 01:11:23 2009 UTC revision 1.17.16.1 by rtoy, Thu Feb 25 20:34:48 2010 UTC
# Line 14  Line 14 
14  ;;;  ;;;
15    
16  (in-package "EXTENSIONS")  (in-package "EXTENSIONS")
17    
18    (intl:textdomain "cmucl")
19    
20  (export '(*command-line-application-arguments* *command-line-words* *command-line-switches*  (export '(*command-line-application-arguments* *command-line-words* *command-line-switches*
21            *command-switch-demons* *command-line-utility-name*            *command-switch-demons* *command-line-utility-name*
22            *command-line-strings* *batch-mode*            *command-line-strings* *batch-mode*
# Line 22  Line 25 
25            defswitch cmd-switch-arg get-command-line-switch))            defswitch cmd-switch-arg get-command-line-switch))
26    
27  (defvar *command-line-application-arguments* ()  (defvar *command-line-application-arguments* ()
28    "A list of all the command line arguments after --")    _N"A list of all the command line arguments after --")
29    
30  (defvar *command-line-switches* ()  (defvar *command-line-switches* ()
31    "A list of cmd-switch's representing the arguments used to invoke    _N"A list of cmd-switch's representing the arguments used to invoke
32    this process.")    this process.")
33    
34  (defvar *command-line-utility-name* ""  (defvar *command-line-utility-name* ""
35    "The string name that was used to invoke this process.")    _N"The string name that was used to invoke this process.")
36    
37  (defvar *command-line-words* ()  (defvar *command-line-words* ()
38    "A list of words between the utility name and the first switch.")    _N"A list of words between the utility name and the first switch.")
39    
40  (defvar *command-line-strings* ()  (defvar *command-line-strings* ()
41    "A list of strings obtained from the command line that invoked this process.")    _N"A list of strings obtained from the command line that invoked this process.")
42    
43  (defvar *command-switch-demons* ()  (defvar *command-switch-demons* ()
44    "An Alist of (\"argument-name\" . demon-function)")    _N"An Alist of (\"argument-name\" . demon-function)")
45    
46  (defvar *batch-mode* nil  (defvar *batch-mode* nil
47    "When True runs lisp with its input coming from standard-input.    _N"When True runs lisp with its input coming from standard-input.
48     If an error is detected returns error code 1, otherwise 0.")     If an error is detected returns error code 1, otherwise 0.")
49    
50  (defstruct (command-line-switch (:conc-name cmd-switch-)  (defstruct (command-line-switch (:conc-name cmd-switch-)
# Line 125  Line 128 
128              (setq str (pop cmd-strings))))))))              (setq str (pop cmd-strings))))))))
129    
130  (defun get-command-line-switch (sname)  (defun get-command-line-switch (sname)
131    "Accepts the name of a switch as a string and returns the value of the    _N"Accepts the name of a switch as a string and returns the value of the
132     switch.  If no value was specified, then any following words are returned.     switch.  If no value was specified, then any following words are returned.
133     If there are no following words, then t is returned.  If the switch was not     If there are no following words, then t is returned.  If the switch was not
134     specified, then nil is returned."     specified, then nil is returned."
# Line 143  Line 146 
146  ;;;; Defining Switches and invoking demons.  ;;;; Defining Switches and invoking demons.
147    
148  (defvar *complain-about-illegal-switches* t  (defvar *complain-about-illegal-switches* t
149    "When set, invoking switch demons complains about illegal switches that have    _N"When set, invoking switch demons complains about illegal switches that have
150     not been defined with DEFSWITCH.")     not been defined with DEFSWITCH.")
151    
152  ;;; This is a list of legal switch names.  DEFSWITCH sets this, and  ;;; This is a list of legal switch names.  DEFSWITCH sets this, and
# Line 164  Line 167 
167        (cond (demon (funcall demon switch))        (cond (demon (funcall demon switch))
168              ((or (member name *legal-cmd-line-switches* :test #'string-equal)              ((or (member name *legal-cmd-line-switches* :test #'string-equal)
169                   (not *complain-about-illegal-switches*)))                   (not *complain-about-illegal-switches*)))
170              (t (warn "~S is an illegal switch" switch)))              (t (warn _"~S is an illegal switch" switch)))
171        (lisp::finish-standard-output-streams))))        (lisp::finish-standard-output-streams))))
172    
173  (defmacro defswitch (name &optional function)  (defmacro defswitch (name &optional function)
174    "Associates function with the switch name in *command-switch-demons*.  Name    _N"Associates function with the switch name in *command-switch-demons*.  Name
175     is a simple-string that does not begin with a hyphen, unless the switch name     is a simple-string that does not begin with a hyphen, unless the switch name
176     really does begin with one.  Function is optional, but defining the switch     really does begin with one.  Function is optional, but defining the switch
177     is necessary to keep invoking switch demons from complaining about illegal     is necessary to keep invoking switch demons from complaining about illegal
# Line 178  Line 181 
181      `(let ((,gname ,name)      `(let ((,gname ,name)
182             (,gfunction ,function))             (,gfunction ,function))
183         (check-type ,gname simple-string)         (check-type ,gname simple-string)
184         (check-type ,gfunction (or symbol function) "a symbol or function")         (check-type ,gfunction (or symbol function) _"a symbol or function")
185         (push ,gname *legal-cmd-line-switches*)         (push ,gname *legal-cmd-line-switches*)
186         (when ,gfunction         (when ,gfunction
187           (push (cons ,gname ,gfunction) *command-switch-demons*)))))           (push (cons ,gname ,gfunction) *command-switch-demons*)))))

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.17.16.1

  ViewVC Help
Powered by ViewVC 1.1.5