Created
November 17, 2014 12:25
-
-
Save mavnn/7bd45615ded82993702f to your computer and use it in GitHub Desktop.
Strongly typed command line arguments
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 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