{"id":15101971,"url":"https://github.com/jjm-one/jjm.one.commandlinetoolwrapper","last_synced_at":"2026-01-19T18:00:56.222Z","repository":{"id":215150039,"uuid":"737764768","full_name":"jjm-one/jjm.one.CommandLineToolWrapper","owner":"jjm-one","description":"A C# library that provides a wrapper for command line tools.","archived":false,"fork":false,"pushed_at":"2024-04-09T07:53:30.000Z","size":326,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-15T11:59:44.459Z","etag":null,"topics":["command-line-tool","csharp","nuget-package","wrapper"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jjm-one.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jonas-merkle","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2024-01-01T12:15:20.000Z","updated_at":"2024-01-02T18:59:42.000Z","dependencies_parsed_at":"2024-09-20T06:02:42.464Z","dependency_job_id":"04d8ab3b-7a54-4acd-983b-f01bd30296b5","html_url":"https://github.com/jjm-one/jjm.one.CommandLineToolWrapper","commit_stats":{"total_commits":54,"total_committers":2,"mean_commits":27.0,"dds":0.03703703703703709,"last_synced_commit":"076779347c2951ec0386bb8c03b9c01a52130f68"},"previous_names":["jjm-one/jjm.one.commandlinetoolwrapper"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/jjm-one/jjm.one.CommandLineToolWrapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjm-one%2Fjjm.one.CommandLineToolWrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjm-one%2Fjjm.one.CommandLineToolWrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjm-one%2Fjjm.one.CommandLineToolWrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjm-one%2Fjjm.one.CommandLineToolWrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jjm-one","download_url":"https://codeload.github.com/jjm-one/jjm.one.CommandLineToolWrapper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjm-one%2Fjjm.one.CommandLineToolWrapper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28578952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T17:42:58.221Z","status":"ssl_error","status_checked_at":"2026-01-19T17:40:54.158Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["command-line-tool","csharp","nuget-package","wrapper"],"created_at":"2024-09-25T18:43:59.129Z","updated_at":"2026-01-19T18:00:56.179Z","avatar_url":"https://github.com/jjm-one.png","language":"C#","funding_links":["https://github.com/sponsors/jonas-merkle"],"categories":[],"sub_categories":[],"readme":"# jjm.one.CommandLineToolWrapper\n\nA C# library that provides a wrapper for command line tools.\n\n## Status\n\n|                       |                       |\n|----------------------:|-----------------------|\n| Build \u0026 Test Status (main) | [![Build\u0026Test](https://github.com/jjm-one/jjm.one.CommandLineToolWrapper/actions/workflows/dotnet.yml/badge.svg)](https://github.com/jjm-one/jjm.one.CommandLineToolWrapper/actions/workflows/dotnet.yml) |\n| Nuget Package Version | [![Nuget Version](https://img.shields.io/nuget/v/jjm.one.CommandLineToolWrapper?style=flat-square)](https://www.nuget.org/packages/jjm.one.CommandLineToolWrapper/) |\n| SonarCloudQuality Gate Status | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=jjm-one_jjm.one.CommandLineToolWrapper\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=jjm-one_jjm.one.CommandLineToolWrapper) |\n\n## Table of contents\n\n- [jjm.one.CommandLineToolWrapper](#jjmonecommandlinetoolwrapper)\n  - [Status](#status)\n  - [Table of contents](#table-of-contents)\n  - [Nuget Package](#nuget-package)\n  - [Full Documentation](#full-documentation)\n  - [Repo](#repo)\n  - [Brief overview of the interfaces and classes](#brief-overview-of-the-interfaces-and-classes)\n    - [`IToolWrapper` Interface](#itoolwrapper-interface)\n    - [`ToolWrapper` Class](#toolwrapper-class)\n    - [`ProcessResult` Class](#processresult-class)\n    - [`ToolWrapper` Constructor](#toolwrapper-constructor)\n    - [`ToolWrapper.RunCommandAsync` Method](#toolwrapperruncommandasync-method)\n  - [Dependency Injection](#dependency-injection)\n\n## Nuget Package\n\nYou can get the latest version of this software as a nuget package form [nuget.org](https://www.nuget.org/packages/jjm.one.CommandLineToolWrapper/)\n\n## Full Documentation\n\nThe full documentation for this package can be found [here](https://jjm-one.github.io/jjm.one.CommandLineToolWrapper/main/doc/html/index.html).\n\n## Repo\n\nThe associated repo for this package can be found [here](https://github.com/jjm-one/jjm.one.CommandLineToolWrapper).\n\n## Brief overview of the interfaces and classes\n\nAll interfaces and classes provided by this package are briefly presented below.\n\n### `IToolWrapper` Interface\n\nThis interface defines a contract for a wrapper around a command line tool. It has a single method, `RunCommandAsync`, which takes a command and its arguments, and returns a `Task` that completes with a `ProcessResult`.\n\n```csharp\npublic interface IToolWrapper\n{\n    Task\u003cProcessResult\u003e RunCommandAsync(string command, string arguments);\n}\n```\n\n### `ToolWrapper` Class\n\nThis class is the default implementation of the `IToolWrapper` interface. It uses an instance of `IProcessRunner` to execute commands, and logs information about the tool's operations. It also has settings for the command line tool and the wrapper itself, which are provided through the constructor.\n\n```csharp\npublic class ToolWrapper : IToolWrapper\n{\n    public ToolWrapper(ToolSettings toolSettings, WrapperSettings wrapperSettings, IProcessRunner? processRunner = null, ILogger\u003cToolWrapper\u003e? logger = null)\n    {\n        // ...\n    }\n\n    public Task\u003cProcessResult\u003e RunCommandAsync(string command, string arguments)\n    {\n        // ...\n    }\n}\n```\n\nYou can use the `ToolWrapper` class to run a command like this:\n\n```csharp\nvar toolWrapper = new ToolWrapper(new ToolSettings(), new WrapperSettings());\nvar result = await toolWrapper.RunCommandAsync(\"echo\", \"Hello, world!\");\nConsole.WriteLine(result.Output);  // Outputs: Hello, world!\n```\n\n### `ProcessResult` Class\n\nThis class represents the result of a process run by the `ToolWrapper`. It contains the exit code of the process and optionally, the output and error messages.\n\n```csharp\npublic class ProcessResult\n{\n    public int ExitCode { get; init; }\n    public string? Output { get; init; }\n    public string? Error { get; init; }\n}\n```\n\nWhen you run a command with the `ToolWrapper`, you get a `ProcessResult`:\n\n```csharp\nvar result = await toolWrapper.RunCommandAsync(\"echo\", \"Hello, world!\");\nConsole.WriteLine(result.ExitCode);  // Outputs: 0\nConsole.WriteLine(result.Output);  // Outputs: Hello, world!\nConsole.WriteLine(result.Error);  // Outputs: null\n```\n\n### `ToolWrapper` Constructor\n\nThe constructor of the `ToolWrapper` class takes in `ToolSettings` and `WrapperSettings` for the command line tool and the wrapper respectively. It also takes an optional `IProcessRunner` and `ILogger\u003cToolWrapper\u003e`. If no `IProcessRunner` is provided, a new `ProcessRunner` is created. If no `ILogger\u003cToolWrapper\u003e` is provided, logging is disabled.\n\n```csharp\npublic ToolWrapper(ToolSettings toolSettings, WrapperSettings wrapperSettings, IProcessRunner? processRunner = null, ILogger\u003cToolWrapper\u003e? logger = null)\n{\n    // ...\n}\n```\n\n### `ToolWrapper.RunCommandAsync` Method\n\nThis method is the implementation of the `RunCommandAsync` method from the `IToolWrapper` interface. It runs a command asynchronously and returns a `ProcessResult`.\n\n```csharp\npublic Task\u003cProcessResult\u003e RunCommandAsync(string command, string arguments)\n{\n    // ...\n}\n```\n\nYou can use this method to run a command like this:\n\n```csharp\nvar result = await toolWrapper.RunCommandAsync(\"echo\", \"Hello, world!\");\nConsole.WriteLine(result.Output);  // Outputs: Hello, world!\n```\n\n## Dependency Injection\n\nThe `AddToolWrapper` method is an extension method for `IServiceCollection` that you can use to register the `ToolWrapper` class and its dependencies in the dependency injection container.\n\nHere's an example of how you can use it in the `ConfigureServices` method of your `Startup.cs` file:\n\n```csharp\npublic void ConfigureServices(IServiceCollection services)\n{\n    // Create instances of ToolSettings and WrapperSettings\n    // You might want to populate these from your configuration\n    var toolSettings = new ToolSettings();\n    var wrapperSettings = new WrapperSettings();\n\n    // Use the AddToolWrapper method to add ToolWrapper and its dependencies\n    services.AddToolWrapper(toolSettings, wrapperSettings);\n\n    // Add other services...\n}\n```\n\nIn this example, `ToolSettings` and `WrapperSettings` are being created as new instances. You might want to populate these from your application's configuration (e.g., from an `appsettings.json` file) instead.\n\nPlease replace `YourNamespace` with the actual namespace where the `AddToolWrapper` method is defined.\n\nAfter you've registered `ToolWrapper` with the `IServiceCollection`, you can have it automatically injected into your classes by adding a parameter of type `IToolWrapper` to the constructor of your class:\n\n```csharp\npublic class MyClass\n{\n    private readonly IToolWrapper _toolWrapper;\n\n    public MyClass(IToolWrapper toolWrapper)\n    {\n        _toolWrapper = toolWrapper;\n    }\n\n    // Use _toolWrapper in your methods...\n}\n```\n\nIn this example, `MyClass` has a dependency on `IToolWrapper`, which will be automatically injected by the .NET Core dependency injection framework when `MyClass` is created.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjjm-one%2Fjjm.one.commandlinetoolwrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjjm-one%2Fjjm.one.commandlinetoolwrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjjm-one%2Fjjm.one.commandlinetoolwrapper/lists"}