All Projects → deinsoftware → toolbox

deinsoftware / toolbox

Licence: MIT license
dein ToolBox - C# .Net Library with utilities like: command line, files, log, platform, shell, system, transform and validation [ Win+Mac+Linux ]

Programming Languages

C#
18002 projects
shell
77523 projects
Batchfile
5799 projects

Projects that are alternatives of or similar to toolbox

Csconsoleformat
.NET C# library for advanced formatting of console output [Apache]
Stars: ✭ 296 (+543.48%)
Mutual labels:  dotnet-standard, dotnet-framework
Theraot
Backporting .NET and more: LINQ expressions in .net 2.0 - nuget Theraot.Core available.
Stars: ✭ 112 (+143.48%)
Mutual labels:  dotnet-standard, dotnet-framework
Linqtotwitter
LINQ Provider for the Twitter API (C# Twitter Library)
Stars: ✭ 401 (+771.74%)
Mutual labels:  dotnet-standard, dotnet-framework
dapr-sidekick-dotnet
Dapr Sidekick for .NET - a lightweight lifetime management component for Dapr
Stars: ✭ 113 (+145.65%)
Mutual labels:  dotnet-standard, dotnet-framework
Appmetrics
App Metrics is an open-source and cross-platform .NET library used to record and report metrics within an application.
Stars: ✭ 1,986 (+4217.39%)
Mutual labels:  dotnet-standard, dotnet-framework
cognite-sdk-dotnet
.NET SDK for Cognite Data Fusion (CDF)
Stars: ✭ 14 (-69.57%)
Mutual labels:  dotnet-standard, dotnet-framework
Minion
Background job system for .NET applications
Stars: ✭ 94 (+104.35%)
Mutual labels:  dotnet-standard, dotnet-framework
Capstone.NET
.NET Core and .NET Framework binding for the Capstone Disassembly Framework
Stars: ✭ 108 (+134.78%)
Mutual labels:  dotnet-standard, dotnet-framework
Dot-Net-Ecosystem
Welcome to the GitHub repository of the .NET Ecosystem. This repository contains the examples for the Pluralsight course: The .NET Ecosystem: The Big Picture. You can download a copy and follow along in the course.
Stars: ✭ 34 (-26.09%)
Mutual labels:  dotnet-standard, dotnet-framework
Entityframeworkcore.cacheable
EntityFrameworkCore second level cache
Stars: ✭ 138 (+200%)
Mutual labels:  dotnet-standard, dotnet-framework
King.Service
Task scheduling for .NET
Stars: ✭ 34 (-26.09%)
Mutual labels:  dotnet-standard, dotnet-framework
Sharpsnmplib
Sharp SNMP Library- Open Source SNMP for .NET and Mono
Stars: ✭ 247 (+436.96%)
Mutual labels:  dotnet-standard, dotnet-framework
colorify
Colorify - C# .Net Console Library with Text Format: colors, alignment and lot more [ Win+Mac+Linux ]
Stars: ✭ 49 (+6.52%)
Mutual labels:  dotnet-standard, dotnet-framework
Mockqueryable
Moking Entity Framework Core operations such ToListAsync, FirstOrDefaultAsync etc
Stars: ✭ 281 (+510.87%)
Mutual labels:  dotnet-standard, dotnet-framework
NeoClient
🦉 Lightweight OGM for Neo4j which support transactions and BOLT protocol.
Stars: ✭ 21 (-54.35%)
Mutual labels:  dotnet-standard, dotnet-framework
Tweetinvi
Tweetinvi, an intuitive Twitter C# library for the REST and Stream API. It supports .NET, .NETCore, UAP (Xamarin)...
Stars: ✭ 812 (+1665.22%)
Mutual labels:  dotnet-standard, dotnet-framework
B2.NET
.NET library for Backblaze's B2 Cloud Storage
Stars: ✭ 63 (+36.96%)
Mutual labels:  dotnet-standard, dotnet-framework
Efcore
EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
Stars: ✭ 10,838 (+23460.87%)
Mutual labels:  dotnet-standard, dotnet-framework
Dotnet Etcd
A C# .NET (dotnet) GRPC client for etcd v3 +
Stars: ✭ 157 (+241.3%)
Mutual labels:  dotnet-standard, dotnet-framework
Krypton-Toolkit-Suite-NET-Core
A update to Component factory's krypton toolkit to support .NET Framework 3.5 to .NET Core
Stars: ✭ 27 (-41.3%)
Mutual labels:  toolbox, dotnet-framework

dein ToolBox [ Win+Mac+Linux ]

github-actions-build github-actions-pack nuget-version nuget-downloads sonar-reliability sonar-security sonar-maintainability sonar-coverage license

ToolBox

ToolBox was created to simplify and automate tasks related to the .Net console. Was born in HardHat project as a Class. Now grown up as a library and can be used by other console applications.

The Code is Dark and Full of Errors! Console is your friend ... don't be afraid!

Menu


Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

What things you need to install?

ToolBox supports netstandard2.1, netcoreapp3.1, net5.0, net6.0 and net7.0 target frameworks.

Installing

ToolBox is available as project or package. We strong recommend add as a NuGet package if don't need make modifications directly on the source code library.

Follow these instructions to add ToolBox in your project.

Add As Package

In your project folder, where is located .csproj file run this command on terminal:

dotnet add package dein.ToolBox

Official documentation: dotnet add package

Add As Reference

Clone ToolBox from GitHub on recommended path. Using this command on terminal:

OS Command
win git clone https://github.com/deinsoftware/toolbox.git "D:\Developer\DEIN\Projects\_devTB"
mac git clone https://github.com/deinsoftware/toolbox.git ~/Developer/DEIN/Projects/_devTB

In your project folder, where is located .csproj file run this command on terminal:

OS Command
win dotnet add reference "D:\Developer\DEIN\Projects\_devCC\ToolBox\ToolBox.csproj"
mac dotnet add reference ~/Developer/DEIN/Projects/_devCC/ToolBox/ToolBox.csproj

Copy Command Bridge files on the path:

  • Bat (Windows)
  • Bash (MacOS / Linux)

Inside your .csproj add Command Bridge files on build:

<Project Sdk="Microsoft.NET.Sdk">
    <ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
        <!-- Command Bridge -->
        <None Update="cmd.sh" CopyToOutputDirectory="PreserveNewest" />
        <None Update="cmd.bat" CopyToOutputDirectory="PreserveNewest" />
        <!-- Projects -->
        <ProjectReference Include="..\..\_devTB\ToolBox\ToolBox.csproj" />
    </ItemGroup>
</Project>

Official documentation: dotnet add reference

Back to menu


Usage

Keep calm, you are almost done. Review this usage steps and enjoy life.

To understand how this library works, take a look inside Sample folder. Better easy to use a guide than words.

Just go to Sample project folder and run this command on terminal:

cd Sample
dotnet run

Files

Include operations relative to File System and implements IFileSystem and ICommandSystem with specific actions and commands per Operative System.

using ToolBox.Files;

On 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.

class Program
{
    public static DiskConfigurator _disk {get; set;}
    public static PathsConfigurator _path {get; set;}

    static void Main(string[] args)
    {
        _disk = new DiskConfigurator(FileSystem.Default);
        switch (OS.GetCurrent())
        {
            case "win":
                _path = new PathsConfigurator(CommandSystem.Win, FileSystem.Default);
                break;
            case "mac":
                _path = new PathsConfigurator(CommandSystem.Mac, FileSystem.Default);
                break;
        }
        //Foo()
        //Bar()
    }
}

If you want to use _path and/or _disk in other class, add a static using to Program class:

using static Namesapace.Program;

replace Namespace with a defined namespace in your project.

Disk

_disk.FilterCreator(extension[]); //Create a Regex with accepted extensions.
_disk.CopyAll(source, destination, overwrite, filter[]); //Copy all files and folder from source to destination
_disk.CopyDirectories(source, destination); //Copy all folder from source to destination
_disk.CopyFiles(source, destination, overwrite, filter[]); //Copy all files from source to destination
_disk.DeleteAll(source, recursive); //Delete all files and folders from source

If you want get Notifications about copy or delete process, need implement the INotificationSystem interface.

public sealed class ConsoleNotificationSystem : INotificationSystem
{
    public void ShowAction(string action, string message)
    {
        _colorify.Wrap($" [{action}] {message}", txtPrimary);
    }
}

And send it as a parameter on DiskConfiguration definition.

_disk = new DiskConfigurator(FileSystem.Default, new ConsoleNotificationSystem());

Paths

_path.Combine(values[]); //Return combined path. Automatic detect `~` as user folder
_path.GetDirectories(path, filter); //Return Folders inside path
_path.GetFiles(path, filter); //Return Files inside path

Log

Include operations relative to Logs and implements the IFileSystem with specific actions and commands per Operative System.

using ToolBox.Log;

On 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).

class Program
{
    private static Config _conf { get; set; }
    private static ILogSystem _log {get; set;}

    static void Main(string[] args)
    {
        _conf = Settings.Read();
        switch (_conf.log.system)
        {
            case "csv":
                _log = new FileLogCsv(FileSystem.Default, _path.Combine("~"), ".application.log");
                break;
            case "txt":
                _log = new FileLogTxt(FileSystem.Default, _path.Combine("~"), ".application.log");
                break;
        }
        //Foo()
        //Bar()
    }
}

Save

_log.Save(exception, logLevel); //Save exception on file

Platform

Platform namespace for Operative System detection and commands.

using ToolBox.Platform;

OS.IsWin();       //Return true on Windows
OS.IsMac();       //Return true on MacOS
OS.IsGnu();       //Return true on Linux

OS.GetCurrent();
//Return "win" on Windows
//Return "mac" on MacOS
//Return "gnu" on Linux

Shell

On the main class Program, add static properties ShellConfigurator and inside the Main method create an instance of the library according the Operative System.

using ToolBox.Bridge;

On 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).

using static ToolBox.Notification;
class Program
{
    public static INotificationSystem _notificationSystem { get; set; }
    public static IBridgeSystem _bridgeSystem { get; set; }
    public static ShellConfigurator _shell { get; set; }

    static void Main(string[] args)
    {
        _notificationSystem = new ConsoleNotificationSystem(); //Or _notificationSystem = NotificationSystem.Default;
        switch (OS.GetCurrent())
        {
            case "win":
                _bridgeSystem = BridgeSystem.Bat;
                break;
            case "mac":
            case "gnu":
                _bridgeSystem = BridgeSystem.Bash;
                break;
        }
        _shell = new ShellConfigurator(_bridgeSystem, _notificationSystem);
        //Foo()
        //Bar()
    }
}

If you want to use _shell in other class, add a static using to Program class:

using static Namesapace.Program;

replace Namespace with a defined namespace in your project.

Notification

If you want customize shell output need implement the INotificationSystem interface or can use default implementation with NotificationSystem.Default static class.

using ToolBox.Notification;
public sealed class ConsoleNotificationSystem : INotificationSystem
{
    private string _pastMessage { get; set; } = "";

    public void StandardOutput(string message)
    {
        var diff = message.Except(_pastMessage).ToArray();
            if (diff.Length <= 2 && message.Contains("%")) //Control Progress Messages
            {
                Console.SetCursorPosition(0, Console.CursorTop - 1);
            }
            _colorify.Wrap($" {message}", txtPrimary);
            _pastMessage = message;
    }

    public void StandardWarning(string message)
    {
        _colorify.Wrap($" {message}", txtWarning);
    }

    public void StandardError(string message)
    {
        _colorify.Wrap($" {message}", txtDanger);
    }

    public void StandardLine()
    {
        _colorify.BlankLines();
    }
}

Browse

_shell.Browse(url); //Open and URL in default browser

Term

Run a command in a shell terminal.

_shell.Term(command);                           //Run a command in hidden mode
_shell.Term(command, Output.Hidden);            //Run a command in hidden mode
_shell.Term(command, Output.Internal);          //Run a command in internal mode, showing his results in same terminal with INotificationSystem implementation
_shell.Term(command, Output.External);          //Run a command in a new terminal window
_shell.Term(command, Output.Internal, path);    //Path parameter define a path where the command needs to be executed

Using Response to receive command result with: code, stdout and stderr

Response result = _shell.Term("dotnet --version", Output.Hidden);
_shell.Result(result.stdout, "Not Installed");
_colorify.WriteLine(result.code.ToString(), txtInfo);
if (result.code == 0){
    _colorify.WriteLine($"Command Works :D", txtSuccess);
} else {
    _colorify.WriteLine(result.stderr, txtDanger);
}

Result

_shell.Result(value);                   //Clean special characters from value and print in terminal.
_shell.Result(value, warningMessage);   //Clean special characters from value and print in terminal or it's empty show the warningMessage.

System

Include operations relative to System.

using ToolBox.System;

Environment Variables

Env.GetValue(key);        //Return value from key
Env.SetValue(key, value); //Set value to key (only for program session, not permanent)
Env.IsNullOrEmpty(key);   //Return true when value from key is defined

Network

Network.GetLocalIPv4();             //Return current ip address
Network.GetOctetsIPv4(ip, number);  //Return ip address with octets defined on number

User

User.GetUserName(); //Return logged username
User.GetMachine();  //Return machine name
User.GetDomain();   //Return domain name

Transform

Include operations relative to Transform Text.

using ToolBox.Transform;

Strings

Strings.CleanSpecialCharacters(value); //Receive an string and clean \r (carriage return) and \n (new line) characters.
Strings.RemoveWords(value, wordsToRemove[]);  //Return value without removed words
Strings.GetWord(value, wordPosition); //Search in value the wordPosition and return the word.
Strings.SplitLines[](value, wordPosition); //Receive a value string and split on array when found \n (New Line) character and return an array with all lines.
Strings.ExtractLine(value, search); //Receive a value string and split on array when found \n (New Line) character and return first line with search value.
Strings.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.

Validations

Include operations relative to Validations.

using ToolBox.Validations;

Boolean

Bool.SomeFalse(values[]);  //Return true if there is false value

Number

Number.IsNumber(value);             //Return true if value is number
Number.IsOnRange(min, value, max);  //Return true if number is between min and max

Strings

Strings.SomeNullOrEmpty(values[]);  //Return true if there is an empty or null value

Web

Web.IsUrl(value); //Return true if value is an http or https valid address

Back to menu


About

Built With

  • .Net - .Net is a free and open-source web framework, developed by Microsoft and the community.
  • VS Code - Code editing redefined.
  • SonarQube - Continuous code quality.

Contributing

Please read CONTRIBUTING for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the ToolBox on GitHub.

Authors

See also the list of contributors who participated in this project.

Sponsors

If this project help you reduce time to develop, you can give me a cup of coffee.

GitHub Sponsors paypal

No sponsors yet! Will you be the first?

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Back to menu

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].