Table of Contents

CliContext Class

Definition

Namespace
DotMake.CommandLine
Assembly
DotMake.CommandLine.dll

Supports command invocation by providing access to parse results and other services.

public class CliContext
Inheritance
CliContext

Constructors

CliContext(CliBindingContext, ParseResult, CancellationToken)

Initializes a new instance of the CliContext class.

Properties

CancellationToken

Gets the token to implement cancellation handling. Available for async command handlers.

Error

Gets the standard error output stream wrapped by a CLI writer that provides styled terminal output (color and text decoration), using ANSI escape sequences when supported and console-native fallbacks otherwise.

The standard error can be used to write error information during the current invocation.

By default, Error is wrapped. The underlying stream can be changed via Error.

Output

Gets the standard output stream wrapped by a CLI writer that provides styled terminal output (color and text decoration), using ANSI escape sequences when supported and console-native fallbacks otherwise.

The standard output can be used to write non-error information during the current invocation.

By default, Out with encoding set to UTF8, is wrapped. The underlying stream can be changed via Output.

Result

Gets the result providing details about the parse operation and methods for binding.

Methods

IsEmpty()

Gets a value indicating whether current command and all its parents are specified without any subcommands, directives, options or arguments.

Note that arguments and options should be optional, if they are required (no default values), then handler will not run and missing error message will be shown.

IsEmptyCommand()

Gets a value indicating whether current command is specified without any arguments or options.

Note that this may return true even if any arguments or options were specified for parent commands. because only arguments or options specified for the current command, are checked.

Note that arguments and options should be optional, if they are required (no default values), then handler will not run and missing error message will be shown.

ShowHelp()

Shows help for current command.

ShowHierarchy(bool)

Shows hierarchy for all commands. It will start from the root command and show a tree. Useful for testing a command.

ShowValues()

Shows parsed values for current command and its arguments and options. Useful for testing a command.