Last active
November 7, 2019 14:11
-
-
Save gsscoder/5076685 to your computer and use it in GitHub Desktop.
Just a snippet of test wrote against an unreleased branch of CommandLine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Reflection | |
open CommandLine | |
open CommandLine.Text | |
[<assembly: AssemblyCopyright("Copyright (c) 2013 Giacomo Stelluti Scala playing with FSharp")>] | |
do() | |
type options() = | |
[<Option(HelpText = "Let your program talk a lot.")>] | |
member val verbose = false with get, set | |
[<Option(HelpText = "A file not used in this program.")>] | |
member val filename = "" with get, set | |
[<ParserState>] | |
member val parserState : ParserState = null with get, set | |
[<EntryPoint>] | |
let main argv = | |
let conf = | |
let mutable sett = new ParserSettings() | |
sett.DynamicAutoBuild <- true | |
sett.HelpWriter <- Console.Error | |
sett | |
use parser = new CommandLine.Parser(conf) | |
let opts = | |
let onExit = new Action(fun() -> printfn "fail!") | |
parser.ParseArguments<options>(argv, onExit) | |
printfn "%A %A" opts.verbose opts.filename | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment