DotCon 7.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DotCon --version 7.3.0
NuGet\Install-Package DotCon -Version 7.3.0
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="DotCon" Version="7.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotCon --version 7.3.0
#r "nuget: DotCon, 7.3.0"
#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 DotCon as a Cake Addin
#addin nuget:?package=DotCon&version=7.3.0

// Install DotCon as a Cake Tool
#tool nuget:?package=DotCon&version=7.3.0

DotCon .NET

DotCon is a lightweight library that provides a simple and consistent interface for executing shell commands in various terminal environments. It follows the Factory Method design pattern to create terminal instances based on different shells (Bash, Cmd, PowerShell, Zsh).

Table of Contents

Features

  • Execute shell commands synchronously and asynchronously.
  • Capture the output of executed commands.
  • Run script actions by parsing and executing corresponding shell commands.
  • Configure terminal options such as redirecting standard output, using shell execution, and creating no window.

Getting Started

Prerequisites

  • .NET 7.0 SDK or later

Installation

You can add the DotCon library to your .NET project using the following methods:

Package Manager Console
dotnet add package DotCon --version 7.3.0

Or download/ clone the project and run the RunDocker.sh file, which will start up a conatiner with the classlib added to a console application.

Usage

Creating a Terminal Instance

To create a terminal instance, you can use one of the following methods:

  1. Create a terminal instance using one of the available shell options.
  2. Execute shell commands or run script actions using the terminal instance.
Terminal.UseBashShell();
Terminal.UseCmdShell();
Terminal.UsePowershellShell();
Terminal.UseZshShell();

Or

Terminal.UseBashShell(options =>
{
    // Configure terminal options
});

Run terminal commands or store script to be run at a later time with the Execute methods.

string output = terminal.Run("ls -la");

string output = await terminal.RunAsync("ls -la");

string output = terminal.ExecuteScript("myScript");

string output = await terminal.ExecuteScriptAsync("myScript");

Try to run commands in the terminal with a similer syntax to the TryParse

Terminal terminal = Terminal.UseBashShell();

string output;
bool success = terminal.TryRun("ls -la", out output);

if (success)
{
    // Handle successful
}
else
{
    // Handle execution error
    Console.WriteLine($"Error: {output}");
}

Contributing

Contributions are welcome! To contribute to this project, follow these steps:

  1. Fork this repository.
  2. Create a new branch: git checkout -b feature/your-feature.
  3. Make your changes and commit them: git commit -m 'Add some feature'.
  4. Push to the branch: git push origin feature/your-feature.
  5. Open a pull request.

Please adhere to the Code of Conduct and maintain clean and concise code.

Licence

Please make sure to update the license section with the appropriate license information for your project.

Contact

For questions or feedback, feel free to reach out to me at simon.k.nyvall@gmail.com.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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.
  • net7.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
8.2.1 229 11/22/2023
8.2.0 101 11/22/2023
7.3.0 210 6/5/2023
7.2.0 149 5/27/2023
7.1.0 146 5/23/2023
7.0.1 149 5/23/2023
7.0.0 149 5/23/2023