Skip to content

Instantly share code, notes, and snippets.

@mavnn
Created November 17, 2014 12:25
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 mavnn/7bd45615ded82993702f to your computer and use it in GitHub Desktop.
Save mavnn/7bd45615ded82993702f to your computer and use it in GitHub Desktop.
Strongly typed command line arguments
open Targ
type InputArgs = Args<"""
v|Verbose|Flag to specify if in verbose mode|Bool|
s|TargetSchema|Set schema (http/https/...)|String|http
u|TargetUrl|Set Url to download from|String|google.com
p|Port|Set port to connect on|Int|80
""">
[<EntryPoint>]
let main argv =
let config = InputArgs argv
if config.Verbose then
printfn "---- I'm in verbose mode! Moar logging! ----"
use client = new System.Net.WebClient()
let uri =
let builder = System.UriBuilder(config.TargetSchema, config.TargetUrl, config.Port)
builder.Uri
client.DownloadString(uri) |> printfn "%s"
if config.Verbose then
printfn "---- I'm still being verbose! ----"
System.Console.ReadLine() |> ignore
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment