-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.fs
42 lines (34 loc) · 1.21 KB
/
Config.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
41
42
namespace VpnGateConnect
open VpnGateConnect
open Argu
type Config = {
DataSource: Cli.DataSourceType * string;
AllowedRegions: string array;
ConfigPaths: string array;
OpenVpnPath: string;
NoColor: bool;
}
module Config =
[<Literal>]
let private DefaultOpenVpnPath = "openvpn"
let private defaultVpnListSource = (Cli.RemoteUrl, "https://www.vpngate.net/api/iphone")
/// Constructs a configuration object from a completed argument parse.
let fromArgs (args: ParseResults<Cli.ArgParser>) = {
DataSource =
args.TryGetResult(<@ Cli.Source @>)
|> Option.defaultValue defaultVpnListSource;
AllowedRegions =
args.TryGetResult(<@ Cli.Regions @>)
|> Option.map List.toArray
|> Option.defaultValue [||]
|> Array.map (fun x -> x.ToLower());
ConfigPaths =
args.TryGetResult(<@ Cli.AppendConfigs @>)
|> Option.map List.toArray
|> Option.defaultValue [||];
OpenVpnPath =
args.TryGetResult(<@ Cli.OpenVpnPath @>)
|> Option.defaultValue DefaultOpenVpnPath
NoColor =
args.Contains(<@ Cli.NoColor @>)
}