Skip to content

Instantly share code, notes, and snippets.

@gsscoder
Last active November 7, 2019 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsscoder/5076685 to your computer and use it in GitHub Desktop.
Save gsscoder/5076685 to your computer and use it in GitHub Desktop.
Just a snippet of test wrote against an unreleased branch of CommandLine
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