-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathFoundryLocalArgumentOptions.cs
More file actions
66 lines (55 loc) · 2.01 KB
/
FoundryLocalArgumentOptions.cs
File metadata and controls
66 lines (55 loc) · 2.01 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using OpenChat.PlaygroundApp.Abstractions;
using OpenChat.PlaygroundApp.Configurations;
using OpenChat.PlaygroundApp.Constants;
namespace OpenChat.PlaygroundApp.Options;
/// <summary>
/// This represents the argument options entity for Foundry Local.
/// </summary>
public class FoundryLocalArgumentOptions : ArgumentOptions
{
/// <summary>
/// Gets or sets the alias of Foundry Local.
/// </summary>
public string? Alias { get; set; }
/// <summary>
/// Gets or sets the Endpoint of FoundryLocal.
/// </summary>
public string? Endpoint { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to disable the automatic FoundryLocal manager and use a manually configured endpoint.
/// </summary>
public bool DisableFoundryLocalManager { get; set; }
/// <inheritdoc/>
protected override void ParseOptions(IConfiguration config, string[] args)
{
var settings = new AppSettings();
config.Bind(settings);
var foundryLocal = settings.FoundryLocal;
this.Alias ??= foundryLocal?.Alias;
this.Endpoint ??= foundryLocal?.Endpoint;
this.DisableFoundryLocalManager = foundryLocal?.DisableFoundryLocalManager ?? false;
for (var i = 0; i < args.Length; i++)
{
switch (args[i])
{
case ArgumentOptionConstants.FoundryLocal.Alias:
if (i + 1 < args.Length)
{
this.Alias = args[++i];
}
break;
case ArgumentOptionConstants.FoundryLocal.Endpoint:
if (i + 1 < args.Length)
{
this.Endpoint = args[++i];
}
break;
case ArgumentOptionConstants.FoundryLocal.DisableFoundryLocalManager:
this.DisableFoundryLocalManager = true;
break;
default:
break;
}
}
}
}