InputCommand Base Class

All command classes must extend the InputCommand base class as one of two required command class components (the other being the Command Attribute). InputCommand provides common functionality to the command, including access to the HostInterface where the command was invoked.


The InputCommand exposes a protected InputCommandOutputCollection which allows the command class to write messages to the console.

protected InputCommandOutputCollection Out { get; }

The InputCommand also defines two switches, Verbose and Debug. Thus, every command can be configured to execute with verbose and debug output turned on or off depending on how the command was invoked. By default, unless these switches are present in the command line, the InputCommandOutputCollection will not write debug or verbose messages to the console respectively.


InputCommand also exposes a Prompt function which allows the command to prompt the user for input. The string parameter passed to the Prompt function will serve as the input prompt printed to the console, and the function returns the user input.

protected string Prompt(string prompt)


InputCommand also exposes a confirm function will allows the command to confirm whether or not an action should proceed (i.e., if the command is going to make permanent changes).

protected bool Confirm(string message, ConfirmationResult defaultResult = ConfirmationResult.Yes)

Confirm returns a Boolean indicating whether or not the user has replied in the affirmative. The message is what is printed to the console as the confirmation request. The defaultResult is the result that is implied if the user presses enter without entering a confirmation. The following image illustrates an example confirmation.



InputCommand exposes two virtual functions, GetDetailsDocumentation and GetExamplesDocumentation that return documentation. As both of these functions return null by default, these functions can be overridden in the extending class to implement further documentation. The values produced by these functions are used by the Help Command.

DefaultParameterSet Property

The DefaultParameterSet property indicates which (if any) parameter set is active during the command invocation.

see also Command API, HostInterface, Help Command, Parameter Sets

Last edited Jun 16, 2013 at 12:32 AM by jeffhewitt, version 10


No comments yet.