-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathProgram.fs
40 lines (31 loc) · 1.21 KB
/
Program.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
module Program
open Argu
open Bullseye
open ProcNet
open CommandLine
[<EntryPoint>]
let main argv =
let argv = if argv.Length = 0 then ["build"] |> Array.ofList else argv
let parser = ArgumentParser.Create<Build>(programName = "./build.sh")
let parsed =
try
let parsed = parser.ParseCommandLine(inputs = argv, raiseOnUsage = true)
Some parsed
with e ->
printfn $"%s{e.Message}"
None
match parsed with
| None -> 2
| Some parsed ->
let target = parsed.GetSubCommand().StepName
Targets.Setup parsed
let swallowTypes = [typeof<ProcExecException>; typeof<ExceptionExiter>]
let shortErrorsFor = (fun e -> swallowTypes |> List.contains (e.GetType()) )
async {
do! Async.SwitchToThreadPool ()
return! Targets.RunTargetsAndExitAsync([target], shortErrorsFor, fun _ -> ":") |> Async.AwaitTask
} |> Async.RunSynchronously
0