using Archiver.Lib; namespace Archiver; public class Program { public static void Main(string[] args) { try { Options options = CommandLine.Parser.Default.ParseArguments(args).Value; if (options is null || options.InputFiles is null || string.IsNullOrEmpty(options.OutputPath)) { Console.WriteLine("[Archiver] Usage: archiver -i -o "); return; } int c = options.InputFiles.Count(); if (c == 0) { Console.WriteLine("[Archiver] Empty input files."); return; } if (c > 1) { Console.WriteLine($"[Archiver] Encode"); Console.WriteLine($"[Archiver] Input : {string.Join(", ", options.InputFiles)}"); Console.WriteLine($"[Archiver] Output: {options.OutputPath}"); ArchiveEncoder.Encode(options.InputFiles, options.OutputPath).ConfigureAwait(false).GetAwaiter().GetResult(); } else { string inputFile = options.InputFiles.ToArray()[0]; if (ArchiveEncoder.IsArchiveFile(inputFile)) { Console.WriteLine($"[Archiver] Decode"); Console.WriteLine($"[Archiver] Input : {inputFile}"); Console.WriteLine($"[Archiver] Output: {options.OutputPath}"); ArchiveDecoder.Decode(inputFile, options.OutputPath).ConfigureAwait(false).GetAwaiter().GetResult(); } else { Console.WriteLine($"[Archiver] Encode"); Console.WriteLine($"[Archiver] Input : {string.Join(',', options.InputFiles)}"); Console.WriteLine($"[Archiver] Output: {options.OutputPath}"); ArchiveEncoder.Encode(inputFile, options.OutputPath).ConfigureAwait(false).GetAwaiter().GetResult(); } } } catch (Exception ex) { Console.WriteLine($"[Archiver] Error: {ex.Message}"); } } }