{"id":22855050,"url":"https://github.com/deinsoftware/toolbox","last_synced_at":"2025-06-16T22:04:18.927Z","repository":{"id":39499384,"uuid":"114773975","full_name":"deinsoftware/toolbox","owner":"deinsoftware","description":"dein ToolBox - C# .Net Library with utilities like: command line, files, log, platform, shell, system, transform and validation [ Win+Mac+Linux ]","archived":false,"fork":false,"pushed_at":"2022-12-14T22:49:43.000Z","size":1296,"stargazers_count":56,"open_issues_count":2,"forks_count":13,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-05T22:04:57.004Z","etag":null,"topics":["command-line","csharp","dotnet","dotnet-core","dotnet-framework","dotnet-standard","hacktoberfest","library","macos","osdetection","toolbox","toolboxes","validation-library","windows","xunit"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/dein.ToolBox","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/deinsoftware.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["deinsoftware"],"custom":["https://paypal.me/equiman/3"]}},"created_at":"2017-12-19T14:20:59.000Z","updated_at":"2025-03-31T10:41:12.000Z","dependencies_parsed_at":"2023-01-29T01:15:25.120Z","dependency_job_id":null,"html_url":"https://github.com/deinsoftware/toolbox","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deinsoftware%2Ftoolbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deinsoftware%2Ftoolbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deinsoftware%2Ftoolbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deinsoftware%2Ftoolbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deinsoftware","download_url":"https://codeload.github.com/deinsoftware/toolbox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253185532,"owners_count":21867865,"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":["command-line","csharp","dotnet","dotnet-core","dotnet-framework","dotnet-standard","hacktoberfest","library","macos","osdetection","toolbox","toolboxes","validation-library","windows","xunit"],"created_at":"2024-12-13T07:09:43.038Z","updated_at":"2025-05-09T03:38:00.698Z","avatar_url":"https://github.com/deinsoftware.png","language":"C#","readme":"# dein ToolBox [ Win+Mac+Linux ]\n\n[![github-actions-build](https://github.com/deinsoftware/toolbox/workflows/build/badge.svg?branch=master)](https://github.com/deinsoftware/toolbox/actions?query=workflow%3Abuild)\n[![github-actions-pack](https://github.com/deinsoftware/toolbox/workflows/pack/badge.svg)](https://github.com/deinsoftware/toolbox/actions?query=workflow%3Apack)\n[![nuget-version](https://img.shields.io/nuget/v/dein.ToolBox.svg)](https://www.nuget.org/packages/dein.ToolBox/)\n[![nuget-downloads](https://img.shields.io/nuget/dt/dein.ToolBox.svg)](https://www.nuget.org/packages/dein.ToolBox/)\n[![sonar-reliability](https://sonarcloud.io/api/project_badges/measure?project=dein%3Atoolbox\u0026metric=reliability_rating)](https://sonarcloud.io/dashboard?id=dein%3Atoolbox)\n[![sonar-security](https://sonarcloud.io/api/project_badges/measure?project=dein%3Atoolbox\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=dein%3Atoolbox)\n[![sonar-maintainability](https://sonarcloud.io/api/project_badges/measure?project=dein%3Atoolbox\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=dein%3Atoolbox)\n[![sonar-coverage](https://sonarcloud.io/api/project_badges/measure?project=dein%3Atoolbox\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=dein%3Atoolbox)\n[![license](https://img.shields.io/github/license/deinsoftware/toolbox)](LICENSE.md)\n\n![ToolBox](.github/social/preview.png \"ToolBox\")\n\n**ToolBox** was created to simplify and automate tasks related to the .Net console. Was born in [HardHat](https://github.com/deinsoftware/hardhat/) project as a Class. Now grown up as a library and can be used by other console applications.\n\n\u003e The Code is Dark and Full of Errors!\n\u003e Console is your friend ... don't be afraid!\n\n## Menu\n\n- [Getting Started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Install](#installing)\n    - [Dependencies](#dependencies)\n    - [Add As Package](#add-as-package)\n    - [Add As Reference](#add-as-reference)\n- [Usage](#usage)\n  - [Files](#files)\n  - [Log](#log)\n  - [Platform](#platform)\n  - [Shell](#shell)\n  - [System](#system)\n  - [Transform](#transform)\n  - [Validations](#validations)\n- [About](#about)\n  - [Built With](#built-with)\n  - [Contributing](#contributing)\n  - [Versioning](#versioning)\n  - [Authors](#authors)\n  - [Sponsors](#sponsors)\n  - [License](#license)\n  - [Acknowledgments](#acknowledgments)\n\n---\n\n## Getting Started\n\nThese instructions will get you a copy of the project up and running on your local machine for development and testing purposes.\n\n### Prerequisites\n\nWhat things you need to install?\n\n- [.Net SDK](https://www.microsoft.com/net/download)\n\n**ToolBox** supports `netstandard2.1`, `netcoreapp3.1`, `net5.0`, `net6.0` and `net7.0` target frameworks.\n\n### Installing\n\n**ToolBox** is available as [project](https://github.com/deinsoftware/toolbox/) or [package](https://www.nuget.org/packages/dein.ToolBox). We strong recommend add as a NuGet package if don't need make modifications directly on the source code library.\n\nFollow these instructions to add **ToolBox** in your project.\n\n#### Add As Package\n\nIn your project folder, where is located .csproj file run this command on terminal:\n\n```terminal\ndotnet add package dein.ToolBox\n```\n\nOfficial documentation: [dotnet add package](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-add-package)\n\n#### Add As Reference\n\nClone **ToolBox** from GitHub on _recommended_ path. Using this command on terminal:\n\n| OS  | Command                                                                                     |\n| --- | ------------------------------------------------------------------------------------------- |\n| win | `git clone https://github.com/deinsoftware/toolbox.git \"D:\\Developer\\DEIN\\Projects\\_devTB\"` |\n| mac | `git clone https://github.com/deinsoftware/toolbox.git ~/Developer/DEIN/Projects/_devTB`    |\n\nIn your project folder, where is located .csproj file run this command on terminal:\n\n| OS  | Command                                                                           |\n| --- | --------------------------------------------------------------------------------- |\n| win | `dotnet add reference \"D:\\Developer\\DEIN\\Projects\\_devCC\\ToolBox\\ToolBox.csproj\"` |\n| mac | `dotnet add reference ~/Developer/DEIN/Projects/_devCC/ToolBox/ToolBox.csproj`    |\n\nCopy Command Bridge files on the path:\n\n- [Bat](https://github.com/deinsoftware/toolbox/blob/master/ToolBox/cmd.bat) (Windows)\n- [Bash](https://github.com/deinsoftware/toolbox/blob/master/ToolBox/cmd.sh) (MacOS / Linux)\n\nInside your .csproj add Command Bridge files on build:\n\n```xml\n\u003cProject Sdk=\"Microsoft.NET.Sdk\"\u003e\n    \u003cItemGroup Condition=\"'$(TargetFramework)' == 'net7.0'\"\u003e\n        \u003c!-- Command Bridge --\u003e\n        \u003cNone Update=\"cmd.sh\" CopyToOutputDirectory=\"PreserveNewest\" /\u003e\n        \u003cNone Update=\"cmd.bat\" CopyToOutputDirectory=\"PreserveNewest\" /\u003e\n        \u003c!-- Projects --\u003e\n        \u003cProjectReference Include=\"..\\..\\_devTB\\ToolBox\\ToolBox.csproj\" /\u003e\n    \u003c/ItemGroup\u003e\n\u003c/Project\u003e\n```\n\nOfficial documentation: [dotnet add reference](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-add-reference)\n\n⇧ [Back to menu](#menu)\n\n---\n\n## Usage\n\nKeep calm, you are almost done. Review this usage steps and enjoy life.\n\nTo understand how this library works, take a look inside [Sample](https://github.com/deinsoftware/toolbox/tree/master/Sample) folder. Better easy to use a  guide than words.\n\nJust go to `Sample` project folder and run this command on terminal:\n\n```terminal\ncd Sample\ndotnet run\n```\n\n### Files\n\nInclude operations relative to File System and implements `IFileSystem` and `ICommandSystem` with specific actions and commands per Operative System.\n\n```csharp\nusing ToolBox.Files;\n```\n\nOn the main class Program, add static properties DiskConfigurator and PathsConfigurator and inside the `Main` method create an instance of the library according the Operative System.\n\n```csharp\nclass Program\n{\n    public static DiskConfigurator _disk {get; set;}\n    public static PathsConfigurator _path {get; set;}\n\n    static void Main(string[] args)\n    {\n        _disk = new DiskConfigurator(FileSystem.Default);\n        switch (OS.GetCurrent())\n        {\n            case \"win\":\n                _path = new PathsConfigurator(CommandSystem.Win, FileSystem.Default);\n                break;\n            case \"mac\":\n                _path = new PathsConfigurator(CommandSystem.Mac, FileSystem.Default);\n                break;\n        }\n        //Foo()\n        //Bar()\n    }\n}\n```\n\nIf you want to use `_path` and/or `_disk` in other class, add a static using to `Program` class:\n\n```csharp\nusing static Namesapace.Program;\n```\n\nreplace Namespace with a defined namespace in your project.\n\n#### Disk\n\n```csharp\n_disk.FilterCreator(extension[]); //Create a Regex with accepted extensions.\n_disk.CopyAll(source, destination, overwrite, filter[]); //Copy all files and folder from source to destination\n_disk.CopyDirectories(source, destination); //Copy all folder from source to destination\n_disk.CopyFiles(source, destination, overwrite, filter[]); //Copy all files from source to destination\n_disk.DeleteAll(source, recursive); //Delete all files and folders from source\n```\n\nIf you want get Notifications about copy or delete process, need implement the `INotificationSystem` interface.\n\n```csharp\npublic sealed class ConsoleNotificationSystem : INotificationSystem\n{\n    public void ShowAction(string action, string message)\n    {\n        _colorify.Wrap($\" [{action}] {message}\", txtPrimary);\n    }\n}\n```\n\nAnd send it as a parameter on `DiskConfiguration` definition.\n\n```csharp\n_disk = new DiskConfigurator(FileSystem.Default, new ConsoleNotificationSystem());\n```\n\n#### Paths\n\n```csharp\n_path.Combine(values[]); //Return combined path. Automatic detect `~` as user folder\n_path.GetDirectories(path, filter); //Return Folders inside path\n_path.GetFiles(path, filter); //Return Files inside path\n```\n\n### Log\n\nInclude operations relative to Logs and implements the `IFileSystem` with specific actions and commands per Operative System.\n\n```csharp\nusing ToolBox.Log;\n```\n\nOn the main class Program, add static properties ILogSystem and inside the `Main` method create an instance of the class according a value (maybe in your config system).\n\n```csharp\nclass Program\n{\n    private static Config _conf { get; set; }\n    private static ILogSystem _log {get; set;}\n\n    static void Main(string[] args)\n    {\n        _conf = Settings.Read();\n        switch (_conf.log.system)\n        {\n            case \"csv\":\n                _log = new FileLogCsv(FileSystem.Default, _path.Combine(\"~\"), \".application.log\");\n                break;\n            case \"txt\":\n                _log = new FileLogTxt(FileSystem.Default, _path.Combine(\"~\"), \".application.log\");\n                break;\n        }\n        //Foo()\n        //Bar()\n    }\n}\n```\n\n#### Save\n\n```csharp\n_log.Save(exception, logLevel); //Save exception on file\n```\n\n### Platform\n\nPlatform namespace for Operative System detection and commands.\n\n```csharp\nusing ToolBox.Platform;\n\nOS.IsWin();       //Return true on Windows\nOS.IsMac();       //Return true on MacOS\nOS.IsGnu();       //Return true on Linux\n\nOS.GetCurrent();\n//Return \"win\" on Windows\n//Return \"mac\" on MacOS\n//Return \"gnu\" on Linux\n```\n\n### Shell\n\nOn the main class Program, add static properties ShellConfigurator and inside the `Main` method create an instance of the library according the Operative System.\n\n```csharp\nusing ToolBox.Bridge;\n```\n\nOn the main class Program, add static properties ILogSystem and inside the `Main` method create an instance of the class according a value (maybe in your config system).\n\n```csharp\nusing static ToolBox.Notification;\n```\n\n```csharp\nclass Program\n{\n    public static INotificationSystem _notificationSystem { get; set; }\n    public static IBridgeSystem _bridgeSystem { get; set; }\n    public static ShellConfigurator _shell { get; set; }\n\n    static void Main(string[] args)\n    {\n        _notificationSystem = new ConsoleNotificationSystem(); //Or _notificationSystem = NotificationSystem.Default;\n        switch (OS.GetCurrent())\n        {\n            case \"win\":\n                _bridgeSystem = BridgeSystem.Bat;\n                break;\n            case \"mac\":\n            case \"gnu\":\n                _bridgeSystem = BridgeSystem.Bash;\n                break;\n        }\n        _shell = new ShellConfigurator(_bridgeSystem, _notificationSystem);\n        //Foo()\n        //Bar()\n    }\n}\n```\n\nIf you want to use `_shell` in other class, add a static using to `Program` class:\n\n```csharp\nusing static Namesapace.Program;\n```\n\nreplace Namespace with a defined namespace in your project.\n\n#### Notification\n\nIf you want customize shell output need implement the `INotificationSystem` interface or can use default implementation with `NotificationSystem.Default` static class.\n\n```csharp\nusing ToolBox.Notification;\n```\n\n```csharp\npublic sealed class ConsoleNotificationSystem : INotificationSystem\n{\n    private string _pastMessage { get; set; } = \"\";\n\n    public void StandardOutput(string message)\n    {\n        var diff = message.Except(_pastMessage).ToArray();\n            if (diff.Length \u003c= 2 \u0026\u0026 message.Contains(\"%\")) //Control Progress Messages\n            {\n                Console.SetCursorPosition(0, Console.CursorTop - 1);\n            }\n            _colorify.Wrap($\" {message}\", txtPrimary);\n            _pastMessage = message;\n    }\n\n    public void StandardWarning(string message)\n    {\n        _colorify.Wrap($\" {message}\", txtWarning);\n    }\n\n    public void StandardError(string message)\n    {\n        _colorify.Wrap($\" {message}\", txtDanger);\n    }\n\n    public void StandardLine()\n    {\n        _colorify.BlankLines();\n    }\n}\n```\n\n#### Browse\n\n```csharp\n_shell.Browse(url); //Open and URL in default browser\n```\n\n#### Term\n\nRun a command in a shell terminal.\n\n```csharp\n_shell.Term(command);                           //Run a command in hidden mode\n_shell.Term(command, Output.Hidden);            //Run a command in hidden mode\n_shell.Term(command, Output.Internal);          //Run a command in internal mode, showing his results in same terminal with INotificationSystem implementation\n_shell.Term(command, Output.External);          //Run a command in a new terminal window\n_shell.Term(command, Output.Internal, path);    //Path parameter define a path where the command needs to be executed\n```\n\nUsing Response to receive command result with: code, stdout and stderr\n\n```csharp\nResponse result = _shell.Term(\"dotnet --version\", Output.Hidden);\n_shell.Result(result.stdout, \"Not Installed\");\n_colorify.WriteLine(result.code.ToString(), txtInfo);\nif (result.code == 0){\n    _colorify.WriteLine($\"Command Works :D\", txtSuccess);\n} else {\n    _colorify.WriteLine(result.stderr, txtDanger);\n}\n```\n\n#### Result\n\n```csharp\n_shell.Result(value);                   //Clean special characters from value and print in terminal.\n_shell.Result(value, warningMessage);   //Clean special characters from value and print in terminal or it's empty show the warningMessage.\n```\n\n### System\n\nInclude operations relative to System.\n\n```csharp\nusing ToolBox.System;\n```\n\n#### Environment Variables\n\n```csharp\nEnv.GetValue(key);        //Return value from key\nEnv.SetValue(key, value); //Set value to key (only for program session, not permanent)\nEnv.IsNullOrEmpty(key);   //Return true when value from key is defined\n```\n\n#### Network\n\n```csharp\nNetwork.GetLocalIPv4();             //Return current ip address\nNetwork.GetOctetsIPv4(ip, number);  //Return ip address with octets defined on number\n```\n\n#### User\n\n```csharp\nUser.GetUserName(); //Return logged username\nUser.GetMachine();  //Return machine name\nUser.GetDomain();   //Return domain name\n```\n\n### Transform\n\nInclude operations relative to Transform Text.\n\n```csharp\nusing ToolBox.Transform;\n```\n\n#### Strings\n\n```csharp\nStrings.CleanSpecialCharacters(value); //Receive an string and clean \\r (carriage return) and \\n (new line) characters.\nStrings.RemoveWords(value, wordsToRemove[]);  //Return value without removed words\nStrings.GetWord(value, wordPosition); //Search in value the wordPosition and return the word.\nStrings.SplitLines[](value, wordPosition); //Receive a value string and split on array when found \\n (New Line) character and return an array with all lines.\nStrings.ExtractLine(value, search); //Receive a value string and split on array when found \\n (New Line) character and return first line with search value.\nStrings.ExtractLine(value, search, wordsToRemove[]); //Receive a value string and split on array when found \\n (New Line) character and return first line with search value and removeWords defined.\n```\n\n### Validations\n\nInclude operations relative to Validations.\n\n```csharp\nusing ToolBox.Validations;\n```\n\n#### Boolean\n\n```csharp\nBool.SomeFalse(values[]);  //Return true if there is false value\n```\n\n#### Number\n\n```csharp\nNumber.IsNumber(value);             //Return true if value is number\nNumber.IsOnRange(min, value, max);  //Return true if number is between min and max\n```\n\n#### Strings\n\n```csharp\nStrings.SomeNullOrEmpty(values[]);  //Return true if there is an empty or null value\n```\n\n#### Web\n\n```csharp\nWeb.IsUrl(value); //Return true if value is an http or https valid address\n```\n\n⇧ [Back to menu](#menu)\n\n---\n\n## About\n\n### Built With\n\n- [.Net](https://dotnet.github.io/) - .Net is a free and open-source web framework, developed by Microsoft and the community.\n- [VS Code](https://code.visualstudio.com/) - Code editing redefined.\n- [SonarQube](https://sonarcloud.io/) - Continuous code quality.\n\n### Contributing\n\nPlease read [CONTRIBUTING](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.\n\n### Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [ToolBox](https://github.com/deinsoftware/toolbox/tags) on GitHub.\n\n### Authors\n\n- **Camilo Martinez** [[Equiman](http://github.com/equiman)]\n\nSee also the list of [contributors](https://github.com/deinsoftware/toolbox/contributors) who participated in this project.\n\n### Sponsors\n\nIf this project help you reduce time to develop, you can give me a cup of coffee.\n\n[![GitHub Sponsors](https://img.shields.io/badge/-GitHub%20Sponsors-gray?style=flat\u0026labelColor=171515\u0026logo=github\u0026logoColor=white\u0026link=https://github.com/sponsors/deinsoftware)](https://github.com/sponsors/deinsoftware)\n[![paypal](https://img.shields.io/badge/-PayPal-gray?style=flat\u0026labelColor=00457C\u0026logo=paypal\u0026logoColor=white\u0026link=https://paypal.me/equiman/3)](https://paypal.me/equiman/3)\n\nNo sponsors yet! Will you be the first?\n\n### License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details.\n\n### Acknowledgments\n\n- [StackOverflow](http://stackoverflow.com): The largest online community for programmers.\n\n⇧ [Back to menu](#menu)\n","funding_links":["https://github.com/sponsors/deinsoftware","https://paypal.me/equiman/3","https://img.shields.io/badge/-GitHub%20Sponsors-gray?style=flat\u0026labelColor=171515\u0026logo=github\u0026logoColor=white\u0026link=https://github.com/sponsors/deinsoftware","https://img.shields.io/badge/-PayPal-gray?style=flat\u0026labelColor=00457C\u0026logo=paypal\u0026logoColor=white\u0026link=https://paypal.me/equiman/3"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeinsoftware%2Ftoolbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeinsoftware%2Ftoolbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeinsoftware%2Ftoolbox/lists"}