[Haskell-cafe] Typed Configuration Files
Ketil Malde
ketil at malde.org
Thu Jan 14 07:11:29 EST 2010
Magnus Therning <magnus at therning.org> writes:
> Seriously, cmdargs is *brilliant*. It's also magic (to me).
On this list, I'm uncertain whether "brilliant" is a warning or a
recommendation, but "magic" is clearly irresistible, so I had a go at
using cmdargs.
And I agree, it is really nice in quickly and succintly getting command
parsing up and working, and in that it most Works As Expected (tm).
Some snags I ran into, which may (or may not) serve to improve
documentation, and which may (or may not) result in some gentle guidande
as to preferred solutions rising to the surface:
- The examples use 'def' a lot, and I mistakenly thought 'empty' would
supply default values. Not so, replace 'def' with the default value
and off you go. 'def' seems to be the "minimum" value for that
particular type.
- As I wanted a single file argument, I tried to use 'args' in
combination with a parameter of type FilePath. Apparently 'args'
wants [FilePath] and appends command line arguments to the default
value. I used 'error "no file bla bla"' as the default value, and
appending to this didn't do much good, as you can imagine. So: use
[FilePath] and check the length manually.
- CmdArgs helpfully provides default --help, --version as well as
--quite and --verbose. For the two former, there's also a nice
default implementation, but presumably the latter two are for use in
the program proper. Unfortunately, I don't know how to get at their
values.
-k
--
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe
mailing list