ByteDev.Cmd 4.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ByteDev.Cmd --version 4.1.0                
NuGet\Install-Package ByteDev.Cmd -Version 4.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ByteDev.Cmd" Version="4.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ByteDev.Cmd --version 4.1.0                
#r "nuget: ByteDev.Cmd, 4.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ByteDev.Cmd as a Cake Addin
#addin nuget:?package=ByteDev.Cmd&version=4.1.0

// Install ByteDev.Cmd as a Cake Tool
#tool nuget:?package=ByteDev.Cmd&version=4.1.0                

ByteDev.Cmd

Library providing functionality to help when writing output from a .NET Console application.

Installation

ByteDev.Cmd has been written as a .NET Standard 2.0 library, so you can consume it from a .NET Core or .NET Framework 4.6.1 (or greater) application.

ByteDev.Cmd is hosted as a package on nuget.org. To install from the Package Manager Console in Visual Studio run:

Install-Package ByteDev.Cmd

Further details can be found on the nuget page.

Code

The repo can be cloned from git bash:

git clone https://github.com/ByteDev/ByteDev.Cmd

A test console application (ByteDev.Cmd.TestApp) is provided for testing and usage examples.

Usage

Public classes provided include Output, Logger, MessageBox, Keyboard, Prompt. The library also contains a namespace for handling input console arguments.

Output class

Provides wrapper functionality around the Console class to make writing out output easier.

Methods include:

  • Write: write text, MessageBox, Table.
  • WriteLine: write line of text.
  • WriteRainbowLine: write text in some crazy rainbow colors 😉.
  • WriteAlignLeft: write left aligned text (padded entire line).
  • WriteAlignRight: write right aligned text (padded entire line).
  • WriteAlignCenter: write center aligned text (padded entire line).
  • WriteAlignToSides: writes some text left aligned and some text right aligned (padded entire line).
  • WriteHorizontalLine: write horizontal line.
  • WriteBlankLines: write n blank lines.

Logger class

Given optional LogLevel, LoggerColorTheme and Output dependencies provides logger style functionality wrapped around the Console class.

Methods include:

  • WriteDebug
  • WriteInfo
  • WriteWarning
  • WriteError
  • WriteCritical

Arguments namespace

Handle console arguments using a CmdArgInfo class. Define what arguments are allowed using the CmdAllowedArg class.

// args is the string array of args from Program.Main

var allowedArgs = new List<CmdAllowedArg>
{
    new CmdAllowedArg('o', false) {LongName = "output", Description = "Output something"},
    new CmdAllowedArg('p', true) {LongName = "path", Description = "Set a path"}
};

var cmdArgInfo = new CmdArgInfo(args, allowedArgs);

When creating an instance of CmdArgInfo if there was any invalid input a CmdArgException will be thrown.

Once you have an instance of CmdArgInfo you can use it to determine what operations to perform:

if (cmdArgInfo.HasArguments)
{
    foreach (var cmdArg in cmdArgInfo.Arguments)
    {
        switch (cmdArg.ShortName)
        {
            case 'o':
                DoSomeOutput();
                break;

            case 'p':
                SetPath(cmdArg.Value);
                break;
        }
    }
}
else
{
    Console.WriteLine(allowedArgs.HelpText());
}

The ByteDev.Cmd.TestApp project has a working example of this.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.0.0 468 4/5/2021
4.2.2 331 3/31/2021
4.2.1 379 12/14/2020
4.1.1 666 4/12/2020
4.1.0 547 12/5/2019
4.0.0 536 11/8/2019
3.1.0 541 11/6/2019
3.0.1 524 11/5/2019
3.0.0 518 11/5/2019
2.1.0 510 11/4/2019
2.0.0 532 10/21/2019
1.2.0 517 10/19/2019
1.1.1 551 10/7/2019
1.1.0 535 10/6/2019
1.0.1 561 8/7/2019
1.0.0 907 6/12/2018