internal ColumnDefinition(TabularOutputSettings settings, string?header, Func <T, string> binder, int minWidth = 2, int maxWidth = -1, bool shrinkIfNeeded = false, bool rightAlign = false) { Header = header; MaxWidth = maxWidth > 0 ? maxWidth : int.MaxValue; _binder = binder; ShrinkIfNeeded = shrinkIfNeeded; _settings = settings; MinWidth = minWidth + _settings.ShrinkReplacement.Length; //we need to add required width for shrink replacement RightAlign = rightAlign; }
/// <summary> /// Displays the list of templates in a table, one row per template group. /// /// The columns displayed are as follows: /// Except where noted, the values are taken from the highest-precedence template in the group. The info could vary among the templates in the group, but shouldn't. /// (There is no check that the info doesn't vary.) /// - Template Name /// - Short Name: displays the all available short names for the group. /// - Language: All languages supported by any template in the group are displayed, with the default language in brackets, e.g.: [C#] /// - Tags /// The columns can be configured via the command args, see <see cref="ITabularOutputArgs"/>/>. /// </summary> internal static void DisplayTemplateList( IEngineEnvironmentSettings engineEnvironmentSettings, IEnumerable <ITemplateInfo> templates, TabularOutputSettings helpFormatterSettings, Reporter reporter, string?selectedLanguage = null) { IReadOnlyCollection <TemplateGroupTableRow> groupsForDisplay = GetTemplateGroupsForListDisplay( templates, selectedLanguage, engineEnvironmentSettings.GetDefaultLanguage(), engineEnvironmentSettings.Environment); DisplayTemplateList(groupsForDisplay, helpFormatterSettings, reporter); }
private static void DisplayTemplateList( IReadOnlyCollection <TemplateGroupTableRow> groupsForDisplay, TabularOutputSettings tabularOutputSettings, Reporter reporter) { TabularOutput <TemplateGroupTableRow> formatter = TabularOutput .For( tabularOutputSettings, groupsForDisplay) .DefineColumn(t => t.Name, out object?nameColumn, LocalizableStrings.ColumnNameTemplateName, shrinkIfNeeded: true, minWidth: 15, showAlways: true) .DefineColumn(t => t.ShortNames, LocalizableStrings.ColumnNameShortName, showAlways: true) .DefineColumn(t => t.Languages, out object?languageColumn, LocalizableStrings.ColumnNameLanguage, TabularOutputSettings.ColumnNames.Language, defaultColumn: true) .DefineColumn(t => t.Type, LocalizableStrings.ColumnNameType, TabularOutputSettings.ColumnNames.Type, defaultColumn: false) .DefineColumn(t => t.Author, LocalizableStrings.ColumnNameAuthor, TabularOutputSettings.ColumnNames.Tags, defaultColumn: false, shrinkIfNeeded: true, minWidth: 10) .DefineColumn(t => t.Classifications, out object?tagsColumn, LocalizableStrings.ColumnNameTags, TabularOutputSettings.ColumnNames.Author, defaultColumn: true) .OrderBy(nameColumn, StringComparer.OrdinalIgnoreCase); reporter.WriteLine(formatter.Layout()); }
internal static TabularOutput <T> For <T>(TabularOutputSettings settings, IEnumerable <T> rows) { return(new TabularOutput <T>(settings, rows)); }