/// <summary> Entry point for the console application </summary> private static async Task Main(string[] args) { var version = GetVersion(); // Greeting UIConsole.Show($"Kronos, at your service.\n{version}\n"); var lu = LatestUpdate(); if (!lu.Equals(version)) { UIConsole.Show( $"The latest release of Kronos is {lu}. You can find it here: https://github.com/Krypton-Nova/Kronos/releases \n"); } // Read settings var unusedUserAgent = Shared.UserAgent; var unusedUserTags = Shared.UserTags; // Run until Quit command is given. while (true) { // Pass initial options to Program, or request user input var commands = UIConsole.UserCommandInput(args); // Run commands sequentially foreach (var command in commands) { await command.Run(); } // Reset initial options args = new string[0]; } }
/// <summary> Quit Kronos </summary> public async Task Run() { UIConsole.Show( $"Kronos downloaded {Math.Ceiling(Shared.BytesDownloaded / 1000.0):0} KiB of data in total.\n"); UIConsole.Show("Goodbye!\n"); await Task.Delay(100); Environment.Exit(0); }
/// <summary> Show an estimated countdown to a region's next update </summary> public async Task Run() { var regions = await RepoRegionDump.Dump(Shared.UserAgent, Shared.UserTags).Regions(true); var targetIndex = -1; // Get target region from argument if it was provided if (argument != null) { targetIndex = regions.FindIndex(r => r.Name.ToLower() == argument.ToLower()); } // Get target region from user (ask again if given target doesn't exist) while (targetIndex < 0) { UIConsole.Show("\nTarget Region: "); var t = UIConsole.GetInput(); t = ResolveRegionName(t); if (t == "") { return; } targetIndex = regions.FindIndex(r => r.Name.ToLower() == t.ToLower()); if (targetIndex == -1) { UIConsole.Show("Region name not found.\n"); } } timer = new Kronos.Commands.Timer(regions[targetIndex].Name); #pragma warning disable CS4014 timer.Run(Shared.UserAgent, Shared.UserTags, true); #pragma warning restore CS4014 // Show timer header UIConsole.Show("Press [Q] to quit Timer.\n\n"); UIConsole.Show($"{" Time".PadRight(9, ' ')} | {"Trigger".PadRight(7, ' ')} | Variance \n"); UIConsole.Show($"{"".PadRight(10, '-')} {"".PadRight(9, '-')} {"".PadRight(12, '-')}\n"); // Display the timer asynchronously so that it counts down consistently. await ShowUpdateTimer(); // Tell timer to stop, if still running (in case user interrupted) timer.Stop(); UIConsole.Show("\n\n"); }