You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

Consolix

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Consolix

Extensions for simple console tools writing. Includes command logic separation, automatic help generation, attribute definition and parsing, input helpers (password, confirm), output helpers (colored output), color scheme definitions, simple menu provider, spinner and progress bar.

1.1.0
Source
nugetNuGet
Version published
Maintainers
1
Created
Source

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.

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.

Keywords

Console

FAQs

Package last updated on 09 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts