Class CommandBase
Base class for all command implementations
Inherited Members
Namespace: Benday.CommandsFramework
Assembly: Benday.CommandsFramework.dll
Syntax
public abstract class CommandBase
Constructors
| Edit this page View SourceCommandBase(CommandExecutionInfo, ITextOutputProvider)
Constructor
Declaration
public CommandBase(CommandExecutionInfo info, ITextOutputProvider outputProvider)
Parameters
Type | Name | Description |
---|---|---|
CommandExecutionInfo | info | Execution information for the requested command |
ITextOutputProvider | outputProvider | Output provider |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
Fields
| Edit this page View Source_OutputProvider
Declaration
protected readonly ITextOutputProvider _OutputProvider
Field Value
Type | Description |
---|---|
ITextOutputProvider |
Properties
| Edit this page View SourceArguments
Arguments and values for the command. These are the combination of the argument definitions with the values from the command line. The values are set when the command is executed.
Declaration
public ArgumentCollection Arguments { get; }
Property Value
Type | Description |
---|---|
ArgumentCollection |
Description
Human readable description of this command
Declaration
public string Description { get; }
Property Value
Type | Description |
---|---|
string |
ExecutionInfo
Property for accessing the raw execution info for the command
Declaration
public CommandExecutionInfo ExecutionInfo { get; }
Property Value
Type | Description |
---|---|
CommandExecutionInfo |
Methods
| Edit this page View SourceDisplayUsage()
Displays the command usage description
Declaration
protected virtual void DisplayUsage()
DisplayUsage(StringBuilder)
Adds the command usage description to the provided string builder
Declaration
protected void DisplayUsage(StringBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
StringBuilder | builder | StringBuilder instance |
DisplayValidationSummary(List<IArgument>)
Creates and displays the validation summary when there are failed argument validations
Declaration
protected virtual void DisplayValidationSummary(List<IArgument> invalidArguments)
Parameters
Type | Name | Description |
---|---|---|
List<IArgument> | invalidArguments | Collection of invalid arguments |
GetArgValueOrRequiredConfigValue(string, string)
Declaration
public string GetArgValueOrRequiredConfigValue(string argumentName, string configValueName)
Parameters
Type | Name | Description |
---|---|---|
string | argumentName | |
string | configValueName |
Returns
Type | Description |
---|---|
string |
GetArguments()
Get the argument definitions for the command execution. These are used to validate the execution but do not have any actual values.
Declaration
public virtual ArgumentCollection GetArguments()
Returns
Type | Description |
---|---|
ArgumentCollection |
SetValuesFromExecutionInfo()
Reads the arguments from the execution info and sets the values on to the argument definitions for the command.
Declaration
protected virtual void SetValuesFromExecutionInfo()
Validate()
Validate the arguments provided using the required argument definition for the command.
Declaration
protected virtual List<IArgument> Validate()
Returns
Type | Description |
---|---|
List<IArgument> | List of invalid arguments |
WriteLine()
Write a new line to the output provider
Declaration
protected virtual void WriteLine()
WriteLine(string)
Write a message to the output provider
Declaration
protected virtual void WriteLine(string text)
Parameters
Type | Name | Description |
---|---|---|
string | text | Message to write |