Skip to content

Instantly share code, notes, and snippets.

@killerswan
Created September 10, 2011 06:24
Show Gist options
  • Save killerswan/1208007 to your computer and use it in GitHub Desktop.
Save killerswan/1208007 to your computer and use it in GitHub Desktop.
args for both interactive and compiled F#
// Copyright © 2011, Kevin Cantu, me@kevincantu.org
//
// Usage: runfsi --nologo --exec args2.fs -- $@
module Simple
open System
open System.IO
let inline (^<|) f a = f a
let args =
#if COMPILED
System.Environment.GetCommandLineArgs()
#endif
#if INTERACTIVE
fsi.CommandLineArgs
#endif
let (me, var1, var2) =
match args with
| [| x; y; z |] ->
(x,y,z)
| _ ->
printfn "%d args given..." (args.Length - 1)
printfn "Usage: %s REF TEST" args.[0]
exit 1
printfn "%s" var1
printfn "%s" var2
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment