Method Write
- Namespace
- Ploch.CommandLine.Spectre.Output
- Assembly
- Ploch.CommandLine.Spectre.dll
Write(IRenderable)
Writes a renderable object to the output.
IOutput Write(IRenderable renderable)
Parameters
renderableIRenderableThe renderable object to write.
Returns
- IOutput
The current output instance for method chaining.
Write<TMessage>(TMessage, IFormatProvider?)
Writes a message to the output with optional formatting.
IOutput Write<TMessage>(TMessage message, IFormatProvider? format = null)
Parameters
messageTMessageThe message to write.
formatIFormatProviderThe format provider to use for formatting the message, or null to use the default format.
Returns
- IOutput
The current output instance for method chaining.
Type Parameters
TMessageThe type of the message.
Remarks
The message is rendered by the registered IMessageWriter whose message type is the most
derived one it matches; an Spectre.Console.Rendering.IRenderable is rendered by the console directly, and a message
no writer accepts is written as text. A string is therefore written by the registered
writer for strings, which by default writes it verbatim: a [ in it is printed, not parsed as a
markup tag, so a path or user input can be passed straight through. To render markup, call
Markup(string) or MarkupInterpolated(FormattableString). A FormattableString message is
handed to the writer for that type, which by default renders it as interpolated markup with its
string holes escaped, but note that an interpolated string literal infers string here, so it has to be
passed as Write<FormattableString>($"...") to take that path. Registering a writer for either
type with AddMessageWriter changes how it renders here and in WriteLine<TMessage>(TMessage);
the decorating members (WriteBold<TMessage>(TMessage?), WriteError<TMessage>(TMessage?) and their
line forms) go through the formatters and Markup(string) instead, so a writer does not affect them.