{"id":17605967,"url":"https://github.com/alastairlundy/CliInvoke","last_synced_at":"2025-10-19T22:31:07.286Z","repository":{"id":259065072,"uuid":"864892733","full_name":"alastairlundy/CliRunner","owner":"alastairlundy","description":"CliRunner is a .NET Library for interacting with Command Line Interfaces,  CliRunner is a library for interacting with Command Line Interfaces and wrapping around executables.","archived":false,"fork":false,"pushed_at":"2025-01-29T16:21:21.000Z","size":491,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T17:19:53.504Z","etag":null,"topics":["cli","csharp-library","dotnet","process","shell"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alastairlundy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-29T12:57:16.000Z","updated_at":"2025-01-29T16:21:24.000Z","dependencies_parsed_at":"2024-11-10T23:24:47.846Z","dependency_job_id":"0672c904-81d4-4c03-9e29-3a16e4c1ad1b","html_url":"https://github.com/alastairlundy/CliRunner","commit_stats":null,"previous_names":["alastairlundy/clirunner"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alastairlundy%2FCliRunner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alastairlundy%2FCliRunner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alastairlundy%2FCliRunner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alastairlundy%2FCliRunner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alastairlundy","download_url":"https://codeload.github.com/alastairlundy/CliRunner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237221157,"owners_count":19274448,"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":["cli","csharp-library","dotnet","process","shell"],"created_at":"2024-10-22T15:12:40.719Z","updated_at":"2025-10-19T22:31:07.278Z","avatar_url":"https://github.com/alastairlundy.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CliInvoke\n\n\u003c!-- Badges --\u003e\n[![Latest NuGet](https://img.shields.io/nuget/v/AlastairLundy.CliInvoke.svg)](https://www.nuget.org/packages/AlastairLundy.CliInvoke/)\n[![Latest Pre-release NuGet](https://img.shields.io/nuget/vpre/AlastairLundy.CliInvoke.svg)](https://www.nuget.org/packages/AlastairLundy.CliInvoke/)\n[![Downloads](https://img.shields.io/nuget/dt/AlastairLundy.CliInvoke.svg)](https://www.nuget.org/packages/AlastairLundy.CliInvoke/)\n![License](https://img.shields.io/github/license/alastairlundy/CliInvoke)\n\n\u003cimg src=\"https://github.com/alastairlundy/CliInvoke/blob/main/.assets/icon.png\" width=\"192\" height=\"192\" alt=\"CliInvoke Logo\"\u003e\n\nCliInvoke is a .NET library for interacting with Command Line Interfaces and wrapping around executables.\n\nLaunch processes, redirect standard input and output streams, await process completion and much more.\n\n## Table of Contents\n* [Features](#features)\n* [Why CliInvoke?](#why-cliinvoke)\n* [Installing CliInvoke](#installing-cliinvoke)\n    * [Installing CliInvoke](#installing-CliInvoke)\n    * [Supported Platforms](#supported-platforms)\n* [CliInvoke Examples](#examples)\n* [Contributing to CliInvoke](#how-to-contribute-to-cliinvoke)\n* [Roadmap](#cliinvokes-roadmap)\n* [License](#license)\n* [Acknowledgements](#acknowledgements)\n\n## Features\n* Clear separation of concerns between Process Configuration Builders, Process Configuration Models, and Invokers.\n* Supports .NET Standard 2.0, .NET 8 and newer TFMs, and has few dependencies.\n* Has Dependency Injection extensions to make using it a breeze.\n* Support for specific specializations such as running executables or commands via Windows Powershell or CMD on Windows \u003csup\u003e1\u003c/sup\u003e\n* [SourceLink](https://learn.microsoft.com/en-us/dotnet/standard/library-guidance/sourcelink) support\n\n\u003csup\u003e1\u003c/sup\u003e Specializations library distributed separately.\n\n## Why CliInvoke?\n\n| Feature                                                                | CliInvoke | CliWrap |                ProcessX                 |\n|------------------------------------------------------------------------|:---------:|:-------:|:---------------------------------------:|\n| Configure and Run External Processes using code written in .NET        |     ✅     |    ✅    | ❌, Uses mixture of .NET and BASH syntax |\n| No Additional Licensing Terms Required for Use                         |     ✅     |    ❌    |                    ✅                    |\n| Uses only managed .NET code                                            |     ✅     |    ❌    |                    ✅                    |\n| Follows Separation of Concerns and the Single Responsibility Principle |     ✅     |    ❌    |                    ❌                    |\n| Allows for alternative Process Runners to be specified and/or used     |     ✅     |    ❌    |                    ❌                    |              \n\n\n## Installing CliInvoke\nCliInvoke is available on [the Nuget Gallery](https://nuget.org) but call be also installed via the ``dotnet`` sdk cli.\n\nThe package(s) to install depends on your use case:\n* For use in a .NET library - Install the [Abstractions Package](#abstractions-package), your developer users can install the Implementation and Dependency Injection packages.\n* For use in a .NET app - Install the [Implementation Package](#implementation-package) and the [Dependency Injection Extensions Package](#dependency-injection-extensions)\n\n### Abstractions Package\n[CliInvoke.Core Nuget](https://nuget.org/packages/AlastairLundy.CliInvoke.Core)\n\n```bash\ndotnet add package AlastairLundy.CliInvoke.Core\n```\n\n### Implementation Package\n\n[CliInvoke Nuget](https://nuget.org/packages/AlastairLundy.CliInvoke)\n\n```bash\ndotnet add package AlastairLundy.CliInvoke\n```\n\n### Extensions Package\n\n[CliInvoke.Extensions Nuget](https://nuget.org/packages/AlastairLundy.CliInvoke.Extensions)\n\n```bash\ndotnet add package AlastairLundy.CliInvoke.Extensions\n```\n\n### Specializations Package\n[CliInvoke.Specializations Nuget](https://nuget.org/packages/AlastairLundy.CliInvoke.Specializations)\n\n```bash\ndotnet add package AlastairLundy.CliInvoke.Specializations\n```\n\n## Supported Platforms\nCliInvoke can currently be added to .NET Standard 2.0, .NET 8, or .NET 9 or newer supported projects.\n\nThe following table details which target platforms are supported for executing commands via CliInvoke. \n\n| Operating System | Support Status                     | Notes                                                                                       |\n|------------------|------------------------------------|---------------------------------------------------------------------------------------------|\n| Windows          | Fully Supported :white_check_mark: |                                                                                             |\n| macOS            | Fully Supported :white_check_mark: |                                                                                             |\n| Mac Catalyst     | Untested Platform :warning:        | Support for this platform has not been tested but should theoretically work.                |\n| Linux            | Fully Supported :white_check_mark: |                                                                                             |\n| FreeBSD          | Fully Supported :white_check_mark: |                                                                                             |\n| Android          | Untested Platform :warning:        | Support for this platform has not been tested but should theoretically work.                |\n| IOS              | Not Supported :x:                  | Not supported due to ``Process.Start()`` not supporting IOS. \u003csup\u003e3\u003c/sup\u003e                   | \n| tvOS             | Not Supported :x:                  | Not supported due to ``Process.Start()`` not supporting tvOS \u003csup\u003e3\u003c/sup\u003e                   |\n| watchOS          | Not Supported :x:                  | Not supported due to ``Process.Start()`` not supporting watchOS \u003csup\u003e4\u003c/sup\u003e                |\n| Browser          | Not Planned :x:                    | Not supported due to not being a valid target Platform for executing programs or processes. |\n\n\u003csup\u003e3\u003c/sup\u003e - See the [Process class documentation](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.start?view=net-9.0#system-diagnostics-process-start) for more info.\n\n\u003csup\u003e4\u003c/sup\u003e - Lack of watchOS support is implied by lack of IOS support since [watchOS is based on IOS](https://en.wikipedia.org/wiki/WatchOS).\n\n**Note:** This library has not been tested on Android or Tizen.\n\n## Examples\n\n### Simple ``ProcessConfiguration`` creation with Factory Pattern\nThis approach uses the ``IProcessConfigurationFactory`` interface factory to create a ``ProcessConfiguration``. It requires fewer parameters and sets up more defaults for you. \n\nIt can be provided with a ``Action\u003cIProcessConfigurationBuilder\u003e configure`` optional parameter where greater control is desired.\n\n#### Non-Buffered Execution Example\nThis example gets a non buffered ``ProcessResult`` that contains basic process exit code, id, and other information.\n\n```csharp\nusing AlastairLundy.CliInvoke.Core.Factories;\nusing AlastairLundy.CliInvoke.Core;\nusing AlastairLundy.CliIinvoke;\n\nusing Microsoft.Extensions.DependencyInjection;\n\n// Dependency Injection setup code ommitted for clarity\n\n// Get IProcessConfigurationFactory \nIProcessConfigurationFactory processConfigFactory = serviceProvider.GetRequiredService\u003cIProcessConfigurationFactory\u003e();\n\n// Get IProcessConfigurationInvoker\nIProcessConfigurationInvoker _invoker_ = serviceProvider.GetRequiredService\u003cIProcessConfigurationInvoker\u003e();\n\n// Simply create the process configuration.\nProcessConfiguration configuration = processConfigFactory.Create(\"path/to/exe\", \"arguments\");\n\n// Run the process configuration and get the results.\nProcessResult result = await _invoker.ExecuteAsync(configuration, CancellationToken.None);\n```\n\n#### Buffered Execution Example\nThis example gets a ``BufferedProcessResult`` which contains redirected StandardOutput and StandardError as strings.\n\n```csharp\nusing AlastairLundy.CliInvoke.Core.Factories;\nusing AlastairLundy.CliInvoke.Core;\nusing AlastairLundy.CliIinvoke;\n\nusing Microsoft.Extensions.DependencyInjection;\n\n// Dependency Injection setup code ommitted for clarity\n\n// Get IProcessConfigurationFactory \nIProcessConfigurationFactory processConfigFactory = serviceProvider.GetRequiredService\u003cIProcessConfigurationFactory\u003e();\n\n// Get IProcessConfigurationInvoker\nIProcessConfigurationInvoker _invoker_ = serviceProvider.GetRequiredService\u003cIProcessConfigurationInvoker\u003e();\n\n// Simply create the process configuration.\nProcessConfiguration configuration = processConfigFactory.Create(\"path/to/exe\", \"arguments\");\n\n// Run the process configuration and get the results.\nBufferedProcessResult result = await _invoker.ExecuteBufferedAsync(configuration, CancellationToken.None);\n```\n\n\n### Advanced Configuration with Builders\n\nThe following examples shows how to configure and build a ``ProcessConfiguration`` depending on whether Buffering the output is desired.\n\n#### Non-Buffered Execution Example\nThis example gets a non buffered ``ProcessResult`` that contains basic process exit code, id, and other information.\n\n```csharp\nusing AlastairLundy.CliInvoke;\nusing AlastairLundy.CliInvoke.Core;\n\nusing AlastairLundy.CliInvoke.Builders;\nusing AlastairLundy.CliInvoke.Core.Builders;\n\nusing Microsoft.Extensions.DependencyInjection;\n\n  //Namespace and class code ommitted for clarity \n\n  // ServiceProvider and Dependency Injection setup code ommitted for clarity\n  \n  IProcessInvoker _processInvoker = serviceProvider.GetRequiredService\u003cIProcessInvoker\u003e();\n\n  // Fluently configure your Command.\n  IProcessConfigurationBuilder builder = new ProcessConfigurationBuilder(\"Path/To/Executable\")\n                            .WithArguments([\"arg1\", \"arg2\"])\n                            .WithWorkingDirectory(\"/Path/To/Directory\");\n  \n  // Build it as a ProcessConfiguration object when you're ready to use it.\n  ProcessConfiguration config = builder.Build();\n  \n  // Execute the process through ProcessInvoker and get the results.\nProcessResult result = await _processConfigInvoker.ExecuteAsync(config);\n```\n\n#### Buffered Execution Example\nThis example gets a ``BufferedProcessResult`` which contains redirected StandardOutput and StandardError as strings.\n\n```csharp\nusing AlastairLundy.CliInvoke;\nusing AlastairLundy.CliInvoke.Builders;\n\nusing AlastairLundy.CliInvoke.Core;\nusing AlastairLundy.CliInvoke.Core.Builders;\n\nusing Microsoft.Extensions.DependencyInjection;\n\n\n  //Namespace and class code ommitted for clarity \n\n  // ServiceProvider and Dependency Injection setup code ommitted for clarity\n  \n  IProcessInvoker _processInvoker = serviceProvider.GetRequiredService\u003cIProcessInvoker\u003e();\n\n  // Fluently configure your Command.\n  IProcessConfigurationBuilder builder = new ProcessConfigurationBuilder(\"Path/To/Executable\")\n                            .WithArguments([\"arg1\", \"arg2\"])\n                            .WithWorkingDirectory(\"/Path/To/Directory\")\n                            .RedirectStandardOutput(true)\n                           .RedirectStandardError(true);\n  \n  // Build it as a ProcessConfiguration object when you're ready to use it.\n  ProcessConfiguration config = builder.Build();\n  \n  // Execute the process through ProcessInvoker and get the results.\nBufferedProcessResult result = await _processInvoker.ExecuteBufferedAsync(config);\n```\n\n## How to Build CliInvoke's code\nPlease see [building-cliinvoke.md](docs/docs/building-cliinvoke.md) for how to build CliInvoke from source.\n\n## How to Contribute to CliInvoke\nPlease see the [CONTRIBUTING.md file](CONTRIBUTING.md) for code and localization contributions.\n\nIf you want to file a bug report or suggest a potential feature to add, please check out the [GitHub issues page](https://github.com/alastairlundy/CliInvoke/issues/) to see if a similar or identical issue is already open.\nIf there isn't already a relevant issue filed, please [file one here](https://github.com/alastairlundy/CliInvoke/issues/new) and follow the respective guidance from the appropriate issue template.\n\n## CliInvoke's Roadmap\nCliInvoke aims to make working with Commands and external processes easier.\n\nWhilst an initial set of features are available in version 1, there is room for more features, and for modifications of existing features in future updates.\n\nFuture updates may focus on one or more of the following:\n* Improved ease of use\n* Improved stability \n* New features\n* Enhancing existing features\n\n## License\nCliInvoke is licensed under the MPL 2.0 license. You can learn more about it [here](https://www.mozilla.org/en-US/MPL/)\n\nIf you use CliInvoke in your project please make an exact copy of the contents of CliInvoke's [LICENSE.txt file](https://github.com/alastairlundy/CliInvoke/blob/main/LICENSE.txt) available either in your third party licenses txt file or as a separate txt file.\n\n### CliInvoke Assets\nCliInvoke's Icon is NOT licensed under the MPL 2.0 license and is licensed under Copyright with all rights reserved to me (Alastair Lundy).\n\nIf you fork CliInvoke and re-distribute it, please replace the usage of the icon unless you have prior written agreements from me. \n\n## Acknowledgements\n\n### Projects\nThis project would like to thank the following projects for their work:\n* [CliWrap](https://github.com/Tyrrrz/CliWrap/) for inspiring this project\n* [Polyfill](https://github.com/SimonCropp/Polyfill) for simplifying .NET Standard 2.0 support\n\nFor more information, please see the [THIRD_PARTY_NOTICES file](https://github.com/alastairlundy/CliInvoke/blob/main/THIRD_PARTY_NOTICES.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falastairlundy%2FCliInvoke","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falastairlundy%2FCliInvoke","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falastairlundy%2FCliInvoke/lists"}