Generated by DocFX

Class Shell

The Shell class is the primary place user can call to get access to shell functionality.

Inheritance
System.Object
Shell
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Dotnet.Shell.API
Assembly: dotnet-shell-lib.dll
Syntax
public class Shell

Constructors

| Improve this Doc View Source

Shell(Boolean)

Initializes a new instance of the Shell class.

Declaration
public Shell(bool loadHistory = true)
Parameters
Type Name Description
System.Boolean loadHistory

Fields

| Improve this Doc View Source

DefaultScriptExtension

The default extension for scripts run through the scripting engine

Declaration
public const string DefaultScriptExtension = ".nsh"
Field Value
Type Description
System.String
| Improve this Doc View Source

ForegroundProcess

The foreground process

Declaration
public ProcessEx ForegroundProcess
Field Value
Type Description
ProcessEx
| Improve this Doc View Source

HistoryLoadedTask

The history loaded task, wait on this to ensure all history elements have been loaded into memory

Declaration
public Task HistoryLoadedTask
Field Value
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

LastExecutedProcess

The last executed process

Declaration
public ProcessEx LastExecutedProcess
Field Value
Type Description
ProcessEx

Properties

| Improve this Doc View Source

AssemblyLocation

Gets the executing program location.

Declaration
public static string AssemblyLocation { get; }
Property Value
Type Description
System.String

The assembly location.

| Improve this Doc View Source

AutoCompletionHandlers

A list of autocompletion handlers which can be used by the user to extend autocompletion results

Declaration
public virtual List<Func<string, int, Task<IEnumerable<Suggestion>>>> AutoCompletionHandlers { get; }
Property Value
Type Description
System.Collections.Generic.List<System.Func<System.String, System.Int32, System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Suggestion>>>>

The autocompletion handlers.

| Improve this Doc View Source

BackgroundProcesses

Gets the current set of background processes.

Declaration
public ProcessEx[] BackgroundProcesses { get; }
Property Value
Type Description
ProcessEx[]

The background processes.

| Improve this Doc View Source

BasePath

Gets the base path. On Linux this is / on Windows C:\

Declaration
public static string BasePath { get; }
Property Value
Type Description
System.String

The base path.

| Improve this Doc View Source

CommandHandlers

Gets or sets the command handler. This is called after the user has hit Enter and can be used to replace what was entered

Declaration
public virtual List<Func<string, string>> CommandHandlers { get; }
Property Value
Type Description
System.Collections.Generic.List<System.Func<System.String, System.String>>

The command handler.

| Improve this Doc View Source

Error

This function can be called to render a pretty error message.

Declaration
public Action<string> Error { get; set; }
Property Value
Type Description
System.Action<System.String>
| Improve this Doc View Source

History

The shell history

Declaration
public virtual List<HistoryItem> History { get; }
Property Value
Type Description
System.Collections.Generic.List<HistoryItem>
| Improve this Doc View Source

HomeDirectory

Gets the home directory.

Declaration
public virtual string HomeDirectory { get; }
Property Value
Type Description
System.String

The home directory.

| Improve this Doc View Source

LastExitCode

Gets or sets the last exit code.

Declaration
public int LastExitCode { get; }
Property Value
Type Description
System.Int32

The last exit code.

| Improve this Doc View Source

LoadAssemblyFromFileAsync

This function can be called to load a .NET DLL into memory

Declaration
public Func<string, Task> LoadAssemblyFromFileAsync { get; }
Property Value
Type Description
System.Func<System.String, System.Threading.Tasks.Task>
| Improve this Doc View Source

LoadScriptFromFileAsync

This function can be called to load script into memory

Declaration
public Func<string, Task> LoadScriptFromFileAsync { get; }
Property Value
Type Description
System.Func<System.String, System.Threading.Tasks.Task>
| Improve this Doc View Source

Paths

Gets the paths.

Declaration
public List<string> Paths { get; }
Property Value
Type Description
System.Collections.Generic.List<System.String>

The paths.

| Improve this Doc View Source

Prompt

Gets or sets the function used to return the prompt string. This function is generally set by the user to customize the prompt

Declaration
public Func<ColorString> Prompt { get; set; }
Property Value
Type Description
System.Func<ColorString>

The prompt function

| Improve this Doc View Source

WorkingDirectory

Gets or sets the working directory.

Declaration
public string WorkingDirectory { get; }
Property Value
Type Description
System.String

The working directory.

Methods

| Improve this Doc View Source

AddCmdAlias(String, String)

Adds a command alias An example of this is Shell.AddCmdAlias("ls", "ls --color=auto ");

Declaration
public void AddCmdAlias(string command, string replacement)
Parameters
Type Name Description
System.String command

The user entered command.

System.String replacement

The C# replacement.

| Improve this Doc View Source

AddCSAlias(String, String)

Adds a shell alias for C# commands An example of this is Shell.AddCSAlias("echo", "Console.WriteLine(&quot;{0}&quot;);");

Declaration
public void AddCSAlias(string command, string replacement)
Parameters
Type Name Description
System.String command

The user entered command.

System.String replacement

The C# replacement.

| Improve this Doc View Source

ChangeDir(String)

API call to changes the working directory.

Declaration
public void ChangeDir(string location)
Parameters
Type Name Description
System.String location

The location.

Exceptions
Type Condition
System.IO.DirectoryNotFoundException
| Improve this Doc View Source

ConvertPathToAbsolute(String)

Converts the a file path to absolute based on the current working directory This is a public API and is used in #load

Declaration
public string ConvertPathToAbsolute(string file)
Parameters
Type Name Description
System.String file

The file path

Returns
Type Description
System.String
Exceptions
Type Condition
System.IO.FileNotFoundException

The file requested: " + file + " does not exist and cannot be loaded

| Improve this Doc View Source

Execute(String, Object)

Executes the an OS command synchronously.

Declaration
public ProcessEx Execute(string input, object r = null)
Parameters
Type Name Description
System.String input

The command line.

System.Object r

The redirection conditions, if any

Returns
Type Description
ProcessEx

Task

| Improve this Doc View Source

ExecuteAsync(String, Object)

Executes the an OS command asynchronously.

Declaration
public Task<ProcessEx> ExecuteAsync(string input, object r = null)
Parameters
Type Name Description
System.String input

The command line.

System.Object r

The redirection conditions, if any

Returns
Type Description
System.Threading.Tasks.Task<ProcessEx>

Task

| Improve this Doc View Source

RemoveCmdAlias(String)

Removes a command alias.

Declaration
public void RemoveCmdAlias(string command)
Parameters
Type Name Description
System.String command

The command.

| Improve this Doc View Source

RemoveCSAlias(String)

Removes a C# alias.

Declaration
public void RemoveCSAlias(string command)
Parameters
Type Name Description
System.String command

The command.

| Improve this Doc View Source

TryReplaceWithCSAlias(String)

Tries to replace the string with an alias which is a piece of C#

Declaration
public string TryReplaceWithCSAlias(string input)
Parameters
Type Name Description
System.String input

The user input command

Returns
Type Description
System.String

Command with possible alias replacement