Class CliDetails
App-facing convenience builder for one-record key/value detail views ("Name: value" panels).
It removes the manual, error-prone pattern of keeping a parallel header (labels) and record
(values) in sync, of hiding optional fields, and of formatting missing values by hand.
CliDetails is a builder, not a new rendering engine: it converts to a CliTable (via ToTable()) and renders through the existing CliTable → CliGrid pipeline. A detail view is always horizontal — header captions become row labels and the single record becomes the value column — so ToTable() forces Horizontal regardless of the applied preset. The default preset is Details.
Use CliDetails for a single record shown as labelled fields. Use CliTable when you have many records, columnar/tabular data, or need full control over header/record construction.
public sealed class CliDetails : CliRenderableComponent, ICliRenderable
- Inheritance
-
CliDetails
- Implements
- Inherited Members
Fields
DefaultMissingDisplay
Default markup-aware display for a missing value when a field is still rendered
(e.g.
Add(label, null)). Muted so missing values read as absent, not as data.public const string DefaultMissingDisplay = "[Muted](not set)[/]"
Field Value
Methods
Add(string, object?, string?, ThemeStyle?)
Adds a field that is always rendered. When the value is missing it renders
missingDisplay (or the default missing display when null).
Use this — not AddOptional(string, object?, string?, ThemeStyle?) — when an absent
value should be shown explicitly, e.g. Add("Database:", db, "(not selected)"). The optional
style applies a semantic theme style to the value (not the label);
e.g. Key for an identity/anchor value or Path
for a filesystem path.public CliDetails Add(string label, object? value, string? missingDisplay = null, ThemeStyle? style = null)
Parameters
labelstringvalueobjectmissingDisplaystringstyleThemeStyle?
Returns
AddKey(string, object?)
Adds a field whose value is an identity/anchor (ID, name, code, slug, group ID, …), styled with
Key. Convenience for
Add(label, value, style: ThemeStyle.Key).
Key values are normally present, so there is intentionally no AddKeyWhen/AddOptionalKey;
for the rare conditional/optional key use the generic styled overload with
Key.public CliDetails AddKey(string label, object? value)
Parameters
Returns
AddLink(string, object?)
Adds a field whose value is a navigable/link value, styled with Link.
This is semantic styling only (no clickable hyperlink). Convenience for
Add(label, value, style: ThemeStyle.Link).public CliDetails AddLink(string label, object? value)
Parameters
Returns
AddOptional(string, object?, string?, ThemeStyle?)
Adds a field only when the value is present; missing values omit the field entirely
(no row is rendered). Contrast with Add(string, object?, string?, ThemeStyle?),
which always renders. The
missingDisplay is accepted for signature symmetry
but never used (a missing value omits the field). The optional style styles
the value when the field is shown.public CliDetails AddOptional(string label, object? value, string? missingDisplay = null, ThemeStyle? style = null)
Parameters
labelstringvalueobjectmissingDisplaystringstyleThemeStyle?
Returns
AddOptionalLink(string, object?)
Adds a link field only when the value is present, styled with Link.
Convenience for
AddOptional(label, value, style: ThemeStyle.Link).public CliDetails AddOptionalLink(string label, object? value)
Parameters
Returns
AddOptionalPath(string, object?)
Adds a path field only when the value is present, styled with Path.
Convenience for
AddOptional(label, value, style: ThemeStyle.Path).public CliDetails AddOptionalPath(string label, object? value)
Parameters
Returns
AddPath(string, object?)
Adds a field whose value is a filesystem/local path, styled with Path.
Convenience for
Add(label, value, style: ThemeStyle.Path).public CliDetails AddPath(string label, object? value)
Parameters
Returns
AddTitle(object, CliFormattingMode, CliFormatter?)
Sets the detail view title from arbitrary content with an explicit
CliFormattingMode (and optional CliFormatter), matching
AddTitle(object, CliFormattingMode, CliFormatter?).
public CliDetails AddTitle(object title, CliFormattingMode formattingMode, CliFormatter? formatter = null)
Parameters
titleobject- The title content. Must not be
null. formattingModeCliFormattingMode- How the content is formatted.
formatterCliFormatter- An optional formatter; when
nullthe preset's title formatter is kept.
Returns
- CliDetails
- This instance, for fluent chaining.
AddTitle(string, CliTextAlignment?)
Sets the detail view 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 CliDetails 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
- CliDetails
- This instance, for fluent chaining.
AddWhen(bool, string, object?, string?, ThemeStyle?)
Adds a field only when
condition is true. When added, the field is
always rendered (like Add(string, object?, string?, ThemeStyle?)), showing the
missing display for a missing value. The optional style styles the value.public CliDetails AddWhen(bool condition, string label, object? value, string? missingDisplay = null, ThemeStyle? style = null)
Parameters
conditionboollabelstringvalueobjectmissingDisplaystringstyleThemeStyle?
Returns
ApplyPreset(CliTableStylePreset, ITheme?)
Selects the table style preset used when this detail view is converted to a
CliTable. Defaults to Details. The preset
controls visual styling only; orientation is always forced to
Horizontal (labels are row headers), even for a non-details
preset such as Roma or Milano.
public CliDetails 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
- CliDetails
- This instance, for fluent chaining.
DefaultWrapping(CliWrapping)
Sets the default wrapping/truncation applied to every field's value that does not
override it via SetWrapping(CliWrapping). This is the same Wrapping
behaviour CliTable uses on data cells, so semantic theme styles are preserved —
wrapping affects layout only. Wrapping needs a width bound to bind: set the shared value-column
width via SetValueWidth(int?, int?, int?), or rely on the detail view being width-constrained.
public CliDetails DefaultWrapping(CliWrapping wrapping)
Parameters
wrappingCliWrapping- The default wrapping/truncation. Must not be
null.
Returns
- CliDetails
- This instance, for fluent chaining.
IsMissing(object?)
The "missing" rule for detail values:
null is missing, and a string that
is empty or all-whitespace is missing. Other values — including false and 0 —
are present. This keeps detail UX clean (blank strings read as "no value") while never hiding
meaningful falsy data.public static bool IsMissing(object? value)
Parameters
valueobject
Returns
SetMissingDisplay(string)
Sets the default display used for missing values across fields. Per-field overrides
(the
missingDisplay argument on Add(string, object?, string?, ThemeStyle?) and friends)
take precedence. The value is markup-aware (e.g. [Muted](n/a)[/]).public CliDetails SetMissingDisplay(string missingDisplay)
Parameters
missingDisplaystring- The default missing display; must not be
null.
Returns
- CliDetails
- This instance, for fluent chaining.
SetTitleAlignment(CliTextAlignment)
Sets the horizontal alignment of the detail view 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 CliDetails SetTitleAlignment(CliTextAlignment alignment)
Parameters
alignmentCliTextAlignment- The title horizontal alignment.
Returns
- CliDetails
- This instance, for fluent chaining.
SetValueWidth(int?, int?, int?)
Sets the width bounds for the single value column shared by all fields (a detail view is
horizontal, so there is exactly one value column). A
maxWidth is what makes
values wrap or truncate; without one, wrapping only takes effect when the whole detail view is
width-constrained. Only non-null arguments are applied. This is a view-level setting,
not per-field, because every value lives in the same column.public CliDetails SetValueWidth(int? width = null, int? minWidth = null, int? maxWidth = null)
Parameters
Returns
- CliDetails
- This instance, for fluent chaining.
SetWrapping(CliWrapping)
Overrides the wrapping/truncation for the value of the most-recently added field, taking
precedence over DefaultWrapping(CliWrapping). When the preceding add was skipped (a missing
AddOptional(string, object?, string?, ThemeStyle?) or a false
AddWhen(bool, string, object?, string?, ThemeStyle?)), this is a no-op — there is
no field to configure. Wrapping needs a width bound to bind — pair it with
SetValueWidth(int?, int?, int?) or a width-constrained detail view.
public CliDetails SetWrapping(CliWrapping wrapping)
Parameters
wrappingCliWrapping- The wrapping/truncation for the last field's value. Must not be
null.
Returns
- CliDetails
- This instance, for fluent chaining.
ToGrid()
Converts the component into a grid for measurement and rendering.
public override CliGrid ToGrid()
Returns
ToTable()
Builds the equivalent CliTable: the chosen preset (forced to horizontal detail
orientation), the optional title, one header element per field (the label), and a single record
carrying the field values. Missing values
are rendered through the field's effective missing display. This is the integration seam —
rendering goes through the normal CliTable → CliGrid pipeline.
public CliTable ToTable()