I find myself wanting a scsh equivalent of "getopt" to do some
(currently relatively trivial) command-line argument parsing.
I can think of a number of ways of doing this:
1) a pretty-much straight copy of the C "getopt()" function.
(which would be somewhat messy in Scheme terms)
2) a macro which looks vaguely like the C idiom used to invoke
getopt()
(getopt ("ab:c" (command-line)) (optarg)
(("a") (set! aflag #t))
(("b") (set! bflag optarg))
(("c") (set! cflag #t))
(else (die-with-usage-message)))
3) something like the perl "getopts.pl", which binds a number of
variables or sets a number of globals based on the values of
command-line switches.
(A secondary issue is, of course, single-character vs. multiple-
character command line options; I'm an agnostic when it comes to that
particular religious war...)
Opinions, anyone?
- Bill
|