{"id":23630736,"url":"https://github.com/simonnyvall/dotcon","last_synced_at":"2025-11-08T10:30:36.027Z","repository":{"id":167592231,"uuid":"643217899","full_name":"SimonNyvall/DotCon","owner":"SimonNyvall","description":"DotCon is a lightweight library that provides a simple and consistent interface for executing shell commands in various terminal environments...","archived":false,"fork":false,"pushed_at":"2023-11-24T09:38:22.000Z","size":115,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T06:30:54.878Z","etag":null,"topics":["bash","cmd","csharp","nuget","powershell","terminal","zsh"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/DotCon","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SimonNyvall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-05-20T13:18:40.000Z","updated_at":"2023-11-23T10:45:08.000Z","dependencies_parsed_at":"2023-11-24T10:47:39.738Z","dependency_job_id":null,"html_url":"https://github.com/SimonNyvall/DotCon","commit_stats":null,"previous_names":["simonnyvall/dotcon"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonNyvall%2FDotCon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonNyvall%2FDotCon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonNyvall%2FDotCon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonNyvall%2FDotCon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SimonNyvall","download_url":"https://codeload.github.com/SimonNyvall/DotCon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239550601,"owners_count":19657616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","cmd","csharp","nuget","powershell","terminal","zsh"],"created_at":"2024-12-28T02:46:41.743Z","updated_at":"2025-11-08T10:30:35.979Z","avatar_url":"https://github.com/SimonNyvall.png","language":"C#","readme":"# DotCon [![.NET](https://github.com/SimonNyvall/DotCon/actions/workflows/dotnet.yml/badge.svg)](https://github.com/SimonNyvall/DotCon/actions/workflows/dotnet.yml)\n\nDotCon 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).\n\n## Table of Contents\n- [Features](#features)\n- [Getting Started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Installation](#installation)\n  - [Usage](#usage)\n- [Contributing](#contributing)\n- [License](#license)\n- [Contact](#contact)\n    \n\n## Features\n\n- Execute shell commands synchronously and asynchronously.\n- Capture the output of executed commands.\n- Run script actions by parsing and executing corresponding shell commands.\n- Configure terminal options such as redirecting standard output, using shell execution, and creating no window.\n\n## Getting Started\n\n### Prerequisites\n\n- .NET 7.0 SDK or later\n\n### Installation\n\nYou can add the DotCon library to your .NET project using the following methods:\n\n#### Package Manager Console\n``` bash\ndotnet add package DotCon --version 8.2.0\n```\n\nOr download/ clone the project and run the RunDocker.sh file, which will start up a conatiner with the classlib added to a console application.\n\n\n### Usage\n\n#### Creating a Terminal Instance\n\nTo create a terminal instance, you can use one of the following methods:\n\n1. Create a terminal instance using one of the available shell options.\n2. Execute shell commands or run script actions using the terminal instance.\n\n\n```csharp\nTerminal.UseBashShell();\nTerminal.UseCmdShell();\nTerminal.UsePowershellShell();\nTerminal.UseZshShell();\n```\nOr\n```csharp\nTerminal.UseBashShell(options =\u003e\n{\n    // Configure terminal options\n});\n```\nRun terminal commands or store script to be run at a later time with the Execute methods.\n```csharp\nstring output = terminal.Run(\"ls -la\");\n\nstring output = await terminal.RunAsync(\"ls -la\");\n\nstring output = terminal.ExecuteScript(\"myScript\");\n\nstring output = await terminal.ExecuteScriptAsync(\"myScript\");\n```\nTry to run commands in the terminal with a similer syntax to the TryParse\n```csharp\nTerminal terminal = Terminal.UseBashShell();\n\nstring output;\nbool success = terminal.TryRun(\"ls -la\", out output);\n\nif (success)\n{\n    // Handle successful\n}\nelse\n{\n    // Handle execution error\n    Console.WriteLine($\"Error: {output}\");\n}\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonnyvall%2Fdotcon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonnyvall%2Fdotcon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonnyvall%2Fdotcon/lists"}