Chrysolite 0.0.1
dotnet add package Chrysolite --version 0.0.1
NuGet\Install-Package Chrysolite -Version 0.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Chrysolite" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Chrysolite --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Chrysolite, 0.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Chrysolite as a Cake Addin #addin nuget:?package=Chrysolite&version=0.0.1 // Install Chrysolite as a Cake Tool #tool nuget:?package=Chrysolite&version=0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Chrysolite
An event-based API for automated control of command-line interface (CLI) applications, using the Observer pattern.
Usage
string appPath = @"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe";
AppInterface myPsAppInterface = new AppInterface(appPath, "Powershell");
int context = 0;
// handle output emitted by the CLI's standard output stream
myPsAppInterface.StandardMessageReceived += (sender, args) => {
// echo the message emitted by PowerShell to stdout
Console.WriteLine(args.Message);
// PowerShell prompts for input follow the pattern:
// PS C:\some\path>
if (Regex.IsMatch(args.Message, @"PS [^>]+>\s*$") == false) { return; }
// the first time we see the input prompt, change directories
if (context == 0)
{
context++;
myPsAppInterface.SendInput("cd \"C:\\my directory\"");
return;
}
// the second time we see the input prompt, run script
if (context == 1)
{
context++;
myPsAppInterface.SendInput(@".\run-some-script.ps1");
return;
}
// third time we see the input prompt, shut down
if (context == 2)
{
myPsAppInterface.Kill();
}
};
// handle output emitted by the CLI's standard error stream
myPsAppInterface.ErrorMessageReceived += (sender, e) =>
{
var ai = sender as AppInterface;
var source = ai!.Description ?? string.Empty;
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine($"[{source}]: {e.Message}");
Console.ResetColor();
};
// handle termination of the CLI instance's process
myPsAppInterface.AppExited += (sender, args) =>
{
WriteSubtitle("We closed PowerShell - all done!");
// Allow the main thread to continue running from where ObserverApplication.Start() was invoked.
// In this example, this effectively terminates this application.
ObserverApplication.Stop();
};
// Hang the application's main thread, allowing this application to respond to events
ObserverApplication.Start();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.1 | 470 | 8/12/2023 |
Initial release