Add options to the environment
* geesh/environment.scm (*options*): New variable. (getopt): New public function. (setopt!): New public function. (*option-names*): New public variable. (*option-letters*): New public variable.
This commit is contained in:
parent
b4a6350887
commit
c83dbcbdc8
|
@ -37,6 +37,10 @@
|
|||
defun!
|
||||
unsetfun!
|
||||
with-arguments
|
||||
getopt
|
||||
setopt!
|
||||
*option-names*
|
||||
*option-letters*
|
||||
call-with-continue
|
||||
continue
|
||||
call-with-break
|
||||
|
@ -234,6 +238,50 @@ made from within the dynamic extent of @var{thunk}."
|
|||
(set! inside-args (program-arguments))
|
||||
(set-program-arguments outside-args)))))
|
||||
|
||||
|
||||
;;; Options.
|
||||
|
||||
(define *options*
|
||||
(map (cut cons <> #f)
|
||||
'(allexport
|
||||
errexit
|
||||
ignoreeof
|
||||
monitor
|
||||
noclobber
|
||||
noglob
|
||||
noexec
|
||||
nolog
|
||||
notify
|
||||
nounset
|
||||
verbose
|
||||
vi
|
||||
xtrace)))
|
||||
|
||||
(define (getopt name)
|
||||
"Get the value of the option named @var{name}."
|
||||
(match (assq name *options*)
|
||||
((_ . value) value)))
|
||||
|
||||
(define (setopt! name value)
|
||||
"Set the value of the option named @var{name} to @var{value}."
|
||||
(match (assq name *options*)
|
||||
((? pair? p) (set-cdr! p value))))
|
||||
|
||||
(define *option-names*
|
||||
(map car *options*))
|
||||
|
||||
(define *option-letters*
|
||||
'((#\a . allexport)
|
||||
(#\e . errexit)
|
||||
(#\m . monitor)
|
||||
(#\C . noclobber)
|
||||
(#\f . noglob)
|
||||
(#\n . noexec)
|
||||
(#\b . notify)
|
||||
(#\u . nounset)
|
||||
(#\v . verbose)
|
||||
(#\x . xtrace)))
|
||||
|
||||
|
||||
;;; Prompts
|
||||
|
||||
|
|
Loading…
Reference in New Issue