C# Class PowerArgs.Cli.PowerArgsRichCommandLineReader

A customized version of the RichTextCommandLineReader that configures tab completion, history, and syntax highlighting for a given command line arguments definition.
Inheritance: RichTextCommandLineReader, ITabCompletionHandler
Show file Open project: adamabdelhamed/PowerArgs Class Usage Examples

Public Methods

Method Description
FindContextualAction ( string firstToken, CommandLineArgumentsDefinition def = null ) : CommandLineAction

Finds the action that matches the given token in the given definition

FindContextualArgument ( string previousToken, CommandLineAction contextualAction, CommandLineArgumentsDefinition def = null ) : System.CommandLineArgument

A helper that detects the argument represented by the current token given a definition.

FindCurrentTokenArgument ( CommandLineAction contextualAction, string currentToken, bool &expectMatchingArg, CommandLineArgumentsDefinition def = null ) : System.CommandLineArgument

A helper that detects the argument represented by the current token given a definition.

FindPreviousNonWhitespaceToken ( RichCommandLineContext readerContext, HighlighterContext highlighterContext ) : string

Searches the reader's tokens for a non whitespace token that preceeds the current token

PowerArgsRichCommandLineReader ( CommandLineArgumentsDefinition definition, List history ) : System

Configures the reader for the given definition and history information.

TryTabComplete ( RichCommandLineContext cliContext ) : bool

Implementation of tab completion that leverages tab completion sources that are registered with the target definition.

Private Methods

Method Description
ConvertContext ( CommandLineArgumentsDefinition definition, RichCommandLineContext innerContext ) : TabCompletionContext
FindNewTabCompletionHooks ( CommandLineArgumentsDefinition definition ) : IEnumerable
FindOldTabCompletionHooks ( CommandLineArgumentsDefinition definition ) : IEnumerable
InitHighlighters ( ) : void
PassThroughOrTryGetAmbientDefinition ( CommandLineArgumentsDefinition def ) : CommandLineArgumentsDefinition

Method Details

FindContextualAction() public static method

Finds the action that matches the given token in the given definition
public static FindContextualAction ( string firstToken, CommandLineArgumentsDefinition def = null ) : CommandLineAction
firstToken string the token to test. If you pass null you will get null back.
def CommandLineArgumentsDefinition The definition to inspect. If null, the ambient definition will be used. If there is no ambient definition and null is passed then this method throws a NullReferenceException.
return CommandLineAction

FindContextualArgument() public static method

A helper that detects the argument represented by the current token given a definition.
public static FindContextualArgument ( string previousToken, CommandLineAction contextualAction, CommandLineArgumentsDefinition def = null ) : System.CommandLineArgument
previousToken string The token to inspect. If you pass null you will get null back.
contextualAction CommandLineAction An action to inspect for a match if the current token does not match a global argument. Pass null to only check global arguments.
def CommandLineArgumentsDefinition The definition to inspect. If null, the ambient definition will be used. If there is no ambient definition and null is passed then this method throws a NullReferenceException.
return System.CommandLineArgument

FindCurrentTokenArgument() public static method

A helper that detects the argument represented by the current token given a definition.
public static FindCurrentTokenArgument ( CommandLineAction contextualAction, string currentToken, bool &expectMatchingArg, CommandLineArgumentsDefinition def = null ) : System.CommandLineArgument
contextualAction CommandLineAction An action to inspect for a match if the current token does not match a global argument. Pass null to only check global arguments.
currentToken string The token to inspect. If you pass null you will get null back.
expectMatchingArg bool This will be set to true if the current token starts with a '-' or a '/' meaning that the token was an argument indicator, even if it didn't match an argument in the definition.
def CommandLineArgumentsDefinition The definition to inspect. If null, the ambient definition will be used. If there is no ambient definition and null is passed then this method throws a NullReferenceException.
return System.CommandLineArgument

FindPreviousNonWhitespaceToken() public static method

Searches the reader's tokens for a non whitespace token that preceeds the current token
public static FindPreviousNonWhitespaceToken ( RichCommandLineContext readerContext, HighlighterContext highlighterContext ) : string
readerContext RichCommandLineContext the reader context to inspect
highlighterContext HighlighterContext the highlighter context to inspect
return string

PowerArgsRichCommandLineReader() public method

Configures the reader for the given definition and history information.
public PowerArgsRichCommandLineReader ( CommandLineArgumentsDefinition definition, List history ) : System
definition CommandLineArgumentsDefinition The definition to use to configure the reader
history List previous command line values that the end user will be able to cycle through using the up and down arrows
return System

TryTabComplete() public method

Implementation of tab completion that leverages tab completion sources that are registered with the target definition.
public TryTabComplete ( RichCommandLineContext cliContext ) : bool
cliContext RichCommandLineContext cintext used internally
return bool