Skip to content

Simple Console extensions to have command separation, use of colors, additional input and output helpers. Get what's missing in standard Console tools you always wanted there to be.

License

Notifications You must be signed in to change notification settings

salixzs/Consolix

Repository files navigation

Consolix

Console applications are quick way to have something done either as a supporting tool in bigger project or something handy to run from time-to-time. Unfortunately the possibilities of console application and default Visual Studio template leaves space for many improvements, which are covered in this console extensions package.

There are numerous packages covering some of aspects (color console, spinner, progress bar, input helpers, command and parameter parsers) and they are more extensive in that one thing they do. This package takes minimum necessary for simple tooling/app build and packs all these things in one convenient package.

To use commands and parameter parsing/mapping to command properties, package expects console application to be created as hosted application (introduced in .Net Core), using dependency injection and other possibilities usually available by default in ASP.NET applications. This includes logging availability and configuration file usage, too.

Build Nuget version NuGet Downloads

If you use and/or like - put a Star to project in GitHub. Talk to your manager to Buy Me A Coffee

Package provides:

  • Creating console commands as separate classes based on provided interface:
    • Necessary command parameter wiring via attribute use on command class properties (read/mapped from command line or from configuration file).
    • Automated validation of parameters and their presence (if mandatory).
    • Automated command(s) on-screen help generation.
    • One (default to run) or multiple command (specify in command line) possibility.
  • Output helpers (with colors!):
    • Simple output coloring (both foreground and background colors).
    • String.Format placeholders bi-coloring.
    • Clear console line, overwrite current console line.
    • Setting predefined color scheme from 4 available in package.
    • Simple menu.
    • Busy indicator (spinner) for long process visualization (does not block working thread).
      • Working status messages along with spinner.
      • Elapsed time display for process.
      • Inline Progress bar.
    • Progress bar
      • Based on currentStep/totalSteps (not percentage!).
      • Shows execution time along with % done.
  • Input helpers:
    • Password input (entered characters replaced with asterisk (*) on screen).
    • Wait for specific keys.
    • Wait for Enter
    • Wait for Escape.
    • Wait for y/n.

Examples

Parameter wiring

Assume we have this cmdline invoking of application:

C:>consoleapp.exe command --start 2022-01-21 --times 10 --deep

This requires these parameters to be assigned to properties in command with appropriate types.
Package allows to do that easily:

[ConsoleOption("start", "Help text", "s")]
public DateTime? StartDate { get; set; }

[ConsoleOption("times", "Help text", "t")]
public int? TimesToRun { get; set; }

[ConsoleOption("deep", "Help text", "d")]
public bool? GoDeep { get; set; }

Spinner (here growing arrow) with elapsed time and status messages

Spinner with time and status messages

Progress bar

Progress bar

Menu

Simple menu

Output coloring

Output coloring

Command auto-help

Command auto-help

Color scheme choices (here: Raspberry)

Raspberry color scheme

Documentation

Repository Wiki has usage documentation and code snippets for package use.

Demo (Sample) project

Repository includes a sample (Demo) project to visualize its possibilities and usage patterns.

About

Simple Console extensions to have command separation, use of colors, additional input and output helpers. Get what's missing in standard Console tools you always wanted there to be.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages