/// <summary> /// Displays help text to the console. /// </summary> protected virtual void ShowHelp() { console.ForegroundColor = ConsoleColor.Yellow; console.WriteLine(new string('-', console.Width - 2)); console.ResetColor(); console.ForegroundColor = ConsoleColor.White; console.Write(@" "); console.WriteLine("Available options:"); console.ForegroundColor = ConsoleColor.Yellow; console.WriteLine(new string('-', console.Width - 2)); console.ResetColor(); console.WriteLine(); ArgumentParser.ShowUsage(CommandLineOutput); }
private void RedrawFooter(bool inplace) { // Scroll enough new lines into view for the text we might want to write. // This helps to reduce flickering of the progress monitor. // We should still do much better than this if we improve the console API // to handle scrolling of independent regions. int oldNewlinesWritten = newlinesWritten; if (inplace) { console.CursorTop -= newlinesWritten - 1; } else { for (int i = 0; i < 5; i++) { console.WriteLine(); } console.CursorTop -= 4; } newlinesWritten = 1; // Write the progress monitor. console.ForegroundColor = ConsoleColor.White; console.Write(StringUtils.TruncateWithEllipsis(Sanitize(ProgressMonitor.TaskName), width - 20).PadRight(width - 19)); if (!ProgressMonitor.IsDone && !double.IsNaN(ProgressMonitor.TotalWorkUnits)) { console.ForegroundColor = ConsoleColor.Yellow; console.Write('['); console.ForegroundColor = ConsoleColor.DarkYellow; console.Write(new string('=', (int)Math.Round(ProgressMonitor.CompletedWorkUnits * 10 / ProgressMonitor.TotalWorkUnits)).PadRight(10)); console.ForegroundColor = ConsoleColor.Yellow; console.Write(@"] "); console.Write(Math.Floor(ProgressMonitor.CompletedWorkUnits * 100 / ProgressMonitor.TotalWorkUnits).ToString()); console.Write('%'); NewLine(inplace); string sanitizedSubTaskName = Sanitize(ProgressMonitor.LeafSubTaskName); if (sanitizedSubTaskName.Length != 0) { console.ForegroundColor = ConsoleColor.Gray; console.Write(@" "); console.Write(StringUtils.TruncateWithEllipsis(sanitizedSubTaskName, width - 3)); NewLine(inplace); } string sanitizedStatus = Sanitize(ProgressMonitor.Leaf.Status); if (sanitizedStatus.Length != 0) { console.ForegroundColor = ConsoleColor.DarkGreen; console.Write(@" "); console.Write(StringUtils.TruncateWithEllipsis(sanitizedStatus, width - 3)); NewLine(inplace); } } else { NewLine(inplace); } if (ProgressMonitor.IsCanceled) { console.ForegroundColor = ConsoleColor.Red; console.Write(@" "); console.Write(ProgressMonitor.IsDone ? Resources.ConsoleProgressMonitor_CanceledBanner : Resources.ConsoleProgressMonitor_CancelingBanner); NewLine(inplace); } console.ResetColor(); // Clear out the remaining dirty lines in place. if (inplace && oldNewlinesWritten > newlinesWritten) { int dirtyLines = oldNewlinesWritten - newlinesWritten; for (int i = 0; i < dirtyLines; i++) { EraseLine(); } console.CursorTop -= dirtyLines; } }