Using F# 2.0 Powerpack ArgParser from C#
This is an update of the technique mentioned in an antique post by Robert Pickering which was referenced by Laurent Le Brun last summer. I've taken Laurent's example of F# usage and ported it to C# in the most direct fashion:
It is possible to streamline this to hide most of the messy type names inside utilities.
One thing I've not managed to do is get the lambda associated with the ArgType.Rest
to fire, even after setting the default handler opt1
to FSharpOption<T>.None
. That -- the default handler -- gets fired every time an otherwise unmatched argument is encountered; the ArgType.Rest
handler looks from the code like it should "just work" so I'm a bit baffled ATM.
LATER: Mystery solved
Of course, I was testing this at a PowerShell prompt -- and the shell was swallowing the unquoted "--" string : there was no "rest" to operate on.
2 comments :
Good morning.
Where do I find the reference for Microsoft.FSharp.Text?
I am using VS10 and have no experience with F#
Thanks
Jda
The Microsoft.FSharp.Text types are drawn from the F# powerpack main assembly (FSharp.PowerPack.dll). Despite (because of?) all the goodness it contains, this is a separate install to the core F# language support.
Post a Comment