add default api url in case of no config file

This commit is contained in:
Alex Bezdieniezhnykh
2024-11-23 11:59:35 +02:00
parent 3b40bd601e
commit 363687b2cd
2 changed files with 19 additions and 10 deletions
+19 -5
View File
@@ -12,7 +12,6 @@ using Azaion.Common.DTO;
using Azaion.Common.DTO.Config;
using Azaion.Common.Extensions;
using Azaion.Common.Services;
using Azaion.Suite.Services;
using Azaion.Dataset;
using Azaion.Suite.Services.DTO;
using CommandLine;
@@ -40,16 +39,31 @@ public partial class App
"Azaion.Dataset.dll"
];
private static readonly IResourceLoader? ResourceLoader;
private static readonly IResourceLoader? ResourceLoader = new ResourceLoader("", "", null!, null!);
static App()
{
var result = Parser.Default.ParseArguments<SuiteCommandLineOptions>(Environment.GetCommandLineArgs());
if (result.Errors.Any())
return;
var configStr = File.ReadAllText(Constants.CONFIG_PATH);
var apiConfig = JsonConvert.DeserializeObject<AppConfig>(configStr)!.ApiConfig;
ApiConfig apiConfig;
try
{
if (File.Exists(Constants.CONFIG_PATH))
throw new FileNotFoundException(Constants.CONFIG_PATH);
var configStr = File.ReadAllText(Constants.CONFIG_PATH);
apiConfig = JsonConvert.DeserializeObject<AppConfig>(configStr)!.ApiConfig;
}
catch (Exception e)
{
Console.WriteLine(e);
apiConfig = new ApiConfig
{
Url = "https://api.azaion.com",
RetryCount = 3,
TimeoutSeconds = 40
};
}
var api = new AzaionApiClient(new HttpClient
{
BaseAddress = new Uri(apiConfig.Url),