C# Class Microsoft.Scripting.Hosting.Shell.CommandLine

Command line hosting service.
Mostra file Open project: jschementi/iron Class Usage Examples

Public Methods

Method Description
CommandLine ( ) : System
GetGlobals ( string name ) : IList
GetMemberNames ( string code ) : IList
Run ( ScriptEngine engine, IConsole console, ConsoleOptions options ) : void

Executes the comand line - depending upon the options provided we will either run a single file, a single command, or enter the interactive loop.

Terminate ( int exitCode ) : void

Protected Methods

Method Description
CreateCommandDispatcher ( ) : ICommandDispatcher
CreateScope ( ) : Scope
ExecuteCommand ( ScriptSource source ) : object
ExecuteCommand ( string command ) : void
GetCommandProperties ( string code ) : ScriptCodeParseResult
GetNextAutoIndentSize ( string text ) : int

Gets the next level for auto-indentation

GetOutputWriter ( bool isErrorOutput ) : TextWriter
Initialize ( ) : void
PrintLogo ( ) : void
ReadLine ( int autoIndentSize ) : string
ReadStatement ( bool &continueInteraction ) : string

Read a statement, which can potentially be a multiple-line statement suite (like a class declaration).

Run ( ) : int

Runs the command line. Languages can override this to provide custom behavior other than: 1. Running a single command 2. Running a file 3. Entering the interactive console loop.

RunCommand ( string command ) : int
RunFile ( string fileName ) : int
RunInteractive ( ) : int

Starts the interactive loop. Performs any initialization necessary before starting the loop and then calls RunInteractiveLoop to start the loop. Returns the exit code when the interactive loop is completed.

TryInteractiveAction ( ) : int?

Attempts to run a single interaction and handle any language-specific exceptions. Base classes can override this and call the base implementation surrounded with their own exception handling. Returns null if successful and execution should continue, or an exit code.

UnhandledException ( Exception e ) : void

Private Methods

Method Description
IsFatalException ( Exception e ) : bool
RunFile ( ScriptSource source ) : int
RunInteractiveLoop ( ) : int
RunOneInteraction ( ) : int?

Parses a single interactive command or a set of statements and executes it. Returns null if successful and execution should continue, or the appropiate exit code. We check if the code read is an interactive command or statements is by checking for NewLine If the code contains NewLine, it's a set of statements (most probably from SendToConsole) If the code does not contain a NewLine, it's an interactive command typed by the user at the prompt

Shutdown ( ) : void
TreatAsBlankLine ( string line, int autoIndentSize ) : bool

Private helper function to see if we should treat the current input as a blank link. We do this if we only have auto-indent text.

Method Details

CommandLine() public method

public CommandLine ( ) : System
return System

CreateCommandDispatcher() protected method

protected CreateCommandDispatcher ( ) : ICommandDispatcher
return ICommandDispatcher

CreateScope() protected method

protected CreateScope ( ) : Scope
return Microsoft.Scripting.Runtime.Scope

ExecuteCommand() protected method

protected ExecuteCommand ( ScriptSource source ) : object
source ScriptSource
return object

ExecuteCommand() protected method

protected ExecuteCommand ( string command ) : void
command string
return void

GetCommandProperties() protected method

protected GetCommandProperties ( string code ) : ScriptCodeParseResult
code string
return ScriptCodeParseResult

GetGlobals() public method

public GetGlobals ( string name ) : IList
name string
return IList

GetMemberNames() public method

public GetMemberNames ( string code ) : IList
code string
return IList

GetNextAutoIndentSize() protected method

Gets the next level for auto-indentation
protected GetNextAutoIndentSize ( string text ) : int
text string
return int

GetOutputWriter() protected method

protected GetOutputWriter ( bool isErrorOutput ) : TextWriter
isErrorOutput bool
return System.IO.TextWriter

Initialize() protected method

protected Initialize ( ) : void
return void

PrintLogo() protected method

protected PrintLogo ( ) : void
return void

ReadLine() protected method

protected ReadLine ( int autoIndentSize ) : string
autoIndentSize int
return string

ReadStatement() protected method

Read a statement, which can potentially be a multiple-line statement suite (like a class declaration).
protected ReadStatement ( bool &continueInteraction ) : string
continueInteraction bool Should the console session continue, or did the user indicate /// that it should be terminated?
return string

Run() protected method

Runs the command line. Languages can override this to provide custom behavior other than: 1. Running a single command 2. Running a file 3. Entering the interactive console loop.
protected Run ( ) : int
return int

Run() public method

Executes the comand line - depending upon the options provided we will either run a single file, a single command, or enter the interactive loop.
public Run ( ScriptEngine engine, IConsole console, ConsoleOptions options ) : void
engine ScriptEngine
console IConsole
options ConsoleOptions
return void

RunCommand() protected method

protected RunCommand ( string command ) : int
command string
return int

RunFile() protected method

protected RunFile ( string fileName ) : int
fileName string
return int

RunInteractive() protected method

Starts the interactive loop. Performs any initialization necessary before starting the loop and then calls RunInteractiveLoop to start the loop. Returns the exit code when the interactive loop is completed.
protected RunInteractive ( ) : int
return int

Terminate() public method

public Terminate ( int exitCode ) : void
exitCode int
return void

TryInteractiveAction() protected method

Attempts to run a single interaction and handle any language-specific exceptions. Base classes can override this and call the base implementation surrounded with their own exception handling. Returns null if successful and execution should continue, or an exit code.
protected TryInteractiveAction ( ) : int?
return int?

UnhandledException() protected method

protected UnhandledException ( Exception e ) : void
e System.Exception
return void