using UniversalTagEditor.Core;

class Program
{
    static async Task Main(string[] args)
    {
        var opt = ParseArgs(args);

        var log = new Progress<string>(Console.WriteLine);
        var prog = new Progress<ProgressInfo>(p =>
            Console.Title = $"UniversalTagEditor {p.Done}/{p.Total}");

        await Runner.RunAsync(opt, log, prog);
    }

    static UteOptions ParseArgs(string[] args)
    {
        string? albumInfo = null;
        string? albumCover = null;
        string? format = null;
        string? workingDirectory = null;
        bool fixTags = false;
        bool enhanceStructure = false;

        for (int i = 0; i < args.Length; i++)
        {
            switch (args[i])
            {
                case "-w": workingDirectory = args[++i]; break;
                case "-a": albumInfo = args[++i]; break;
                case "-f": format = args[++i]; break;
                case "-c": albumCover = args[++i]; break;
                case "--fix-tags": fixTags = true; break;
                case "--enhance-structure": enhanceStructure = true; break;
            }
        }

        if (string.IsNullOrWhiteSpace(workingDirectory))
            throw new ArgumentException("Нужен -w <path>");

        return new UteOptions
        {
            WorkingDirectory = workingDirectory,
            AlbumInfoCsv = albumInfo,
            AlbumCover = albumCover,
            Format = format,
            FixTags = fixTags,
            EnhanceStructure = enhanceStructure,
            MaxDegreeOfParallelism = 4
        };
    }
}