holy! the server app is finished & model is nice now

This commit is contained in:
Schedel Pascal
2024-08-23 11:58:07 +02:00
parent 860c061b98
commit 82429a2f69
22 changed files with 88 additions and 650 deletions

View File

@@ -0,0 +1,59 @@
using Mono.Options;
using System.Diagnostics.CodeAnalysis;
namespace OwnChar.Server;
internal class ServerOptions
{
private readonly OptionSet options;
public string? DbServer { get; set; }
public string? DbDatabase { get; set; }
public string? DbUser { get; set; }
public string? DbPassword { get; set; }
public string? ApiUrl { get; set; }
public ServerOptions(string[] args)
{
options = new()
{
{
"url=",
"Sets the api server url.",
dbhost => DbServer = dbhost
},
{
"host=",
"Sets the database server address.",
dbhost => DbServer = dbhost
},
{
"db=",
"Sets the database name.",
dbhost => DbServer = dbhost
},
{
"usr=",
"Sets the database user.",
dbhost => DbServer = dbhost
},
{
"pwd=",
"Sets the database password.",
dbhost => DbServer = dbhost
}
};
options.Parse(args);
}
[MemberNotNullWhen(true, nameof(ApiUrl), nameof(DbServer), nameof(DbDatabase), nameof(DbUser), nameof(DbPassword))]
public bool IsValid()
{
return !string.IsNullOrWhiteSpace(ApiUrl)
&& !string.IsNullOrWhiteSpace(DbServer)
&& !string.IsNullOrWhiteSpace(DbDatabase)
&& !string.IsNullOrWhiteSpace(DbUser)
&& !string.IsNullOrWhiteSpace(DbPassword);
}
}