2023-08-24 13:35:07 +02:00
|
|
|
|
using Logging;
|
2024-06-02 00:09:03 +02:00
|
|
|
|
using GlaxArguments;
|
2023-08-24 13:35:07 +02:00
|
|
|
|
|
|
|
|
|
namespace Tranga;
|
|
|
|
|
|
|
|
|
|
public partial class Tranga : GlobalBase
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
2024-06-02 00:09:03 +02:00
|
|
|
|
Argument downloadLocation = new (new[] { "-d", "--downloadLocation" }, 1, "Directory to which downloaded Manga are saved");
|
|
|
|
|
Argument workingDirectory = new (new[] { "-w", "--workingDirectory" }, 1, "Directory in which application-data is saved");
|
|
|
|
|
Argument consoleLogger = new (new []{"-c", "--consoleLogger"}, 0, "Enables the consoleLogger");
|
|
|
|
|
Argument fileLogger = new (new []{"-f", "--fileLogger"}, 0, "Enables the fileLogger");
|
|
|
|
|
Argument fPath = new (new []{"-l", "--fPath"}, 1, "Log Folder Path");
|
2023-08-24 13:35:07 +02:00
|
|
|
|
|
2024-06-02 00:09:03 +02:00
|
|
|
|
Argument[] arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
downloadLocation,
|
|
|
|
|
workingDirectory,
|
|
|
|
|
consoleLogger,
|
|
|
|
|
fileLogger,
|
|
|
|
|
fPath
|
|
|
|
|
};
|
|
|
|
|
ArgumentFetcher fetcher = new (arguments);
|
|
|
|
|
Dictionary<Argument, string[]> fetched = fetcher.Fetch(args);
|
|
|
|
|
|
|
|
|
|
string? directoryPath = fetched.TryGetValue(fPath, out string[]? path) ? path[0] : null;
|
2024-03-05 02:35:37 +01:00
|
|
|
|
if (directoryPath is not null && !Directory.Exists(directoryPath))
|
|
|
|
|
Directory.CreateDirectory(directoryPath);
|
2023-08-24 13:35:07 +02:00
|
|
|
|
|
|
|
|
|
List<Logger.LoggerType> enabledLoggers = new();
|
2024-06-02 00:09:03 +02:00
|
|
|
|
if(fetched.ContainsKey(consoleLogger))
|
2023-08-24 13:35:07 +02:00
|
|
|
|
enabledLoggers.Add(Logger.LoggerType.ConsoleLogger);
|
2024-06-02 00:09:03 +02:00
|
|
|
|
if (fetched.ContainsKey(fileLogger))
|
2023-08-24 13:35:07 +02:00
|
|
|
|
enabledLoggers.Add(Logger.LoggerType.FileLogger);
|
2024-03-05 02:35:37 +01:00
|
|
|
|
Logger logger = new(enabledLoggers.ToArray(), Console.Out, Console.OutputEncoding, directoryPath);
|
2023-08-24 13:35:07 +02:00
|
|
|
|
|
2024-06-02 00:09:03 +02:00
|
|
|
|
bool dlp = fetched.TryGetValue(downloadLocation, out string[]? downloadLocationPath);
|
2024-08-26 12:36:35 +02:00
|
|
|
|
bool wdp = fetched.TryGetValue(workingDirectory, out string[]? workingDirectoryPath);
|
2023-08-24 13:35:07 +02:00
|
|
|
|
|
2024-08-26 12:36:35 +02:00
|
|
|
|
if (wdp)
|
|
|
|
|
TrangaSettings.LoadFromWorkingDirectory(workingDirectoryPath![0]);
|
2024-08-26 13:09:33 +02:00
|
|
|
|
else
|
|
|
|
|
TrangaSettings.CreateOrUpdate();
|
2024-08-26 12:36:35 +02:00
|
|
|
|
if(dlp)
|
|
|
|
|
TrangaSettings.CreateOrUpdate(downloadDirectory: downloadLocationPath![0]);
|
2023-08-24 13:35:07 +02:00
|
|
|
|
|
2024-08-26 12:36:35 +02:00
|
|
|
|
Tranga _ = new (logger);
|
2023-08-24 13:35:07 +02:00
|
|
|
|
}
|
|
|
|
|
}
|