Skip to main content

CommandResult

A class in Root.Township, Alta.Console.

What a console command returns: a result string or an exception, plus the command that ran. The generic CommandResult<T> subclass carries a typed result.

Constructors​

MemberWhat it is
CommandResult(string resultString, Command command)Creates a CommandResult from command.
CommandResult(Command command)Creates a CommandResult from command.

Fields​

MemberWhat it is
protected static Logger loggerShared NLog logger the results are written to.

Properties​

MemberWhat it is
Command Command { get; private set; }The console command that produced this result.
Exception Exception { get; set; }The exception the command threw, or null if it succeeded.
virtual string ResultString { get; }The result as text. VoidResult uses "Success"; the generic version uses its result's ToString.

Methods​

MemberWhat it is
static CommandResult ErrorResult(Exception exception, Command command)Makes a result that wraps an exception thrown by the command.
virtual void Log()Writes the result to the console log at trace level. The generic version can print tables or JSON.
static CommandResult VoidResult(Command command)Makes a plain "Success" result for commands that return nothing.

Used in​

Members of other types that take, return or hold a CommandResult: