--- On Sat 27/12/08, Abdulaziz Ghuloum <[email protected]> wrote: > On Dec 27, 2008, at 2:31 PM, Jens Axel Soegaard wrote: > > > FWIW here is the PLT version of command line parsing. > > > > > http://docs.plt-scheme.org/reference/Command-Line_Parsing.html > > > http://svn.plt-scheme.org/plt/trunk/collects/scheme/cmdline.ss > > Much better! I need to think about it some more. Thanks. >
I've done a simple (yet quite powerful, at least for my needs) utility for
parsing command line options in Gambit-C.
As an exercise, i've ported it to Ikarus, see attachments.
Little description:
(let-opts ((foo #\f "Foo doc" foo-default)
(bar #\b "Bar doc" bar-default)
(usage "[options] args")
argv)
body)
The program here can parse --foo or -f and --bar or -b, and create parameter
"foo" and "bar". Types are inferred from default values.
If boolean, no argument needed.
A function "usage" is create and available in "body". This funtion prints name
of script, followed by the string that in passed in its creation, and a list of
option with their help.
Argv is a list of command line arguments, as returned by (command-line) and it
is mutate by removal of all parsed option. So, in "body", it is a list of
non-option args.
It's just a quick port, but maybe it can be of some interest.
Gambit version has worked quite well for me.
--marco
getopts.sls
Description: Binary data
test-getopts.ss
Description: Binary data
