Class CliList<T>
App-facing convenience builder for list command output: a column-per-field, record-per-item table.
It removes the manual, error-prone pattern of rendering list headings, spacing, indentation, loops,
and per-column formatting by hand with MarkupLine(string).
CliList<T> is a builder, not a new rendering engine: Render(IEnumerable<T>) projects the items into a CliTable (one header element per column, one record per item) and rendering goes through the existing CliTable → CliGrid pipeline. Columns may carry a semantic ThemeStyle applied to the column's values — use AddKeyColumn(string, Func<T, object?>) for identity/anchor values (Key) and AddPathColumn(string, Func<T, object?>) for path values (Path).
Use CliList<T> for list output, CliDetails for single-record show/details output, and CliTable directly only when lower-level table control is needed.
public sealed class CliList<T>
Type Parameters
T- The item/record type the list renders.
- Inheritance
-
CliList<T>
- Inherited Members
Methods
AddColumn(string, Func<T, object?>, ThemeStyle?)
Adds a column with header
label and a selector that
projects each item to a cell value. The optional style applies a semantic
theme style to the column's values (not the header); when null the preset's body
styling is used.public CliList<T> AddColumn(string label, Func<T, object?> selector, ThemeStyle? style = null)
Parameters
labelstringselectorFunc<T, object>styleThemeStyle?
Returns
- CliList<T>
- This instance, for fluent chaining.
AddKeyColumn(string, Func<T, object?>)
Adds a column whose values are identity/anchors (IDs, names, codes, slugs, group IDs, …), styled
with Key. Convenience for
AddColumn(label, selector, style: ThemeStyle.Key).public CliList<T> AddKeyColumn(string label, Func<T, object?> selector)
Parameters
Returns
- CliList<T>
AddLinkColumn(string, Func<T, object?>)
Adds a column whose values are navigable/link values, styled with Link.
This is semantic styling only (no clickable hyperlink). Convenience for
AddColumn(label, selector, style: ThemeStyle.Link).public CliList<T> AddLinkColumn(string label, Func<T, object?> selector)
Parameters
Returns
- CliList<T>
AddPathColumn(string, Func<T, object?>)
Adds a column whose values are filesystem/local paths, styled with Path.
Convenience for
AddColumn(label, selector, style: ThemeStyle.Path).public CliList<T> AddPathColumn(string label, Func<T, object?> selector)
Parameters
Returns
- CliList<T>
AddTitle(object, CliFormattingMode, CliFormatter?)
Sets the list title from arbitrary content with an explicit CliFormattingMode
(and optional CliFormatter), matching
AddTitle(object, CliFormattingMode, CliFormatter?).
public CliList<T> AddTitle(object title, CliFormattingMode formattingMode, CliFormatter? formatter = null)
Parameters
titleobjectformattingModeCliFormattingModeformatterCliFormatter
Returns
- CliList<T>
AddTitle(string, CliTextAlignment?)
Sets the list title from preformatted, markup-aware content (matching
AddTitle(string)). The title uses the preset's title style. The optional
alignment overrides the title's horizontal alignment (layout only, semantic
title style is preserved); when null the preset's title alignment is kept. Alignment can
also be set separately via SetTitleAlignment(CliTextAlignment).public CliList<T> AddTitle(string title, CliTextAlignment? alignment = null)
Parameters
titlestring- The title text; TigerCli markup is honoured. Must not be
null. alignmentCliTextAlignment?- Optional title horizontal alignment;
nullkeeps the preset default.
Returns
- CliList<T>
- This instance, for fluent chaining.
ApplyPreset(CliTableStylePreset, ITheme?)
Selects the table style preset used when the list is rendered. Defaults to
Default. A list is always vertical (columns are fields,
records are items); orientation-locked detail presets are unsuitable here.
public CliList<T> ApplyPreset(CliTableStylePreset preset, ITheme? theme = null)
Parameters
presetCliTableStylePreset- The built-in preset (city or alias) to apply.
themeITheme- The theme that resolves the preset; defaults to the current theme.
Returns
- CliList<T>
- This instance, for fluent chaining.
DefaultWrapping(CliWrapping)
Sets the default wrapping/truncation applied to every column's values that does not
override it via SetWrapping(CliWrapping). This mirrors CliTable wrapping (it is
the same Wrapping behaviour on the column's data cells), so semantic
theme styles are preserved — wrapping affects layout only. Wrapping needs a width bound to bind:
set one per column via SetWidth(int?, int?, int?), or rely on the list being width-constrained
(the rendered table's soft/hard max width) so over-wide columns wrap/truncate.
public CliList<T> DefaultWrapping(CliWrapping wrapping)
Parameters
wrappingCliWrapping- The default wrapping/truncation. Must not be
null.
Returns
- CliList<T>
- This instance, for fluent chaining.
Render(IEnumerable<T>)
Projects
items into a renderable CliTable: the chosen preset,
the optional title, one header element per column (carrying its semantic value style), and one
record per item. An empty items sequence yields a header-only table — a
consistent default empty state that still shows the columns; commands that want a custom empty
message can branch before calling Render(IEnumerable<T>). Pass the result to
Render(CliRenderableComponent).public CliTable Render(IEnumerable<T> items)
Parameters
itemsIEnumerable<T>- The items to render, one record per item. Must not be
null.
Returns
Exceptions
- InvalidOperationException
- No columns were added.
SetTitleAlignment(CliTextAlignment)
Sets the horizontal alignment of the list title (left, center, or right), overriding the
preset's default title alignment. Affects layout only — the title's semantic style and
ThemeStyle behaviour are preserved. Applies whether the title is set via
AddTitle(string, CliTextAlignment?) or the formatting-mode overload.
public CliList<T> SetTitleAlignment(CliTextAlignment alignment)
Parameters
alignmentCliTextAlignment- The title horizontal alignment.
Returns
- CliList<T>
- This instance, for fluent chaining.
SetWidth(int?, int?, int?)
Sets width bounds (fixed
width and/or minWidth /
maxWidth) for the most-recently added column. A maxWidth
is what makes a column wrap or truncate its values; without a width bound, wrapping only takes
effect when the whole list is width-constrained. Only non-null arguments are applied.public CliList<T> SetWidth(int? width = null, int? minWidth = null, int? maxWidth = null)
Parameters
Returns
- CliList<T>
- This instance, for fluent chaining.
Exceptions
- InvalidOperationException
- No column has been added yet.
SetWrapping(CliWrapping)
Overrides the wrapping/truncation for the most-recently added column (from the preceding
AddColumn(string, Func<T, object?>, ThemeStyle?) / AddKeyColumn(string, Func<T, object?>) / AddPathColumn(string, Func<T, object?>) /
AddLinkColumn(string, Func<T, object?>)), taking precedence over DefaultWrapping(CliWrapping). Wrapping
needs a width bound to bind — pair it with SetWidth(int?, int?, int?) or a width-constrained list.
public CliList<T> SetWrapping(CliWrapping wrapping)
Parameters
wrappingCliWrapping- The wrapping/truncation for the last column. Must not be
null.
Returns
- CliList<T>
- This instance, for fluent chaining.
Exceptions
- InvalidOperationException
- No column has been added yet.