ShellProgressBar 4.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package ShellProgressBar --version 4.1.1                
NuGet\Install-Package ShellProgressBar -Version 4.1.1                
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="ShellProgressBar" Version="4.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ShellProgressBar --version 4.1.1                
#r "nuget: ShellProgressBar, 4.1.1"                
#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 ShellProgressBar as a Cake Addin
#addin nuget:?package=ShellProgressBar&version=4.1.1

// Install ShellProgressBar as a Cake Tool
#tool nuget:?package=ShellProgressBar&version=4.1.1                

ShellProgressBar

visualize (concurrent) progress in your console application

This is a great little library to visualize long running command line tasks.

.NET Core ready!

It also supports spawning child progress bars which allows you to visualize dependencies and concurrency rather nicely.

Tested on OSX

example osx

and Windows

example win cmd

(Powershell works too, see example further down)

Install

Get it on nuget: http://www.nuget.org/packages/ShellProgressBar/

Usage

Usage is really straightforward

const int totalTicks = 10;
var options = new ProgressBarOptions
{
    ProgressCharacter = '─',
    ProgressBarOnBottom = true
};
using (var pbar = new ProgressBar(totalTicks, "Initial message", options))
{
    pbar.Tick(); //will advance pbar to 1 out of 10.
    //we can also advance and update the progressbar text
    pbar.Tick("Step 2 of 10"); 
}

Options

Progress bar position

const int totalTicks = 10;
var options = new ProgressBarOptions
{
	ProgressCharacter = '─',
	ProgressBarOnBottom = true
};
using (var pbar = new ProgressBar(totalTicks, "progress bar is on the bottom now", options))
{
	TickToCompletion(pbar, totalTicks, sleep: 500);
}

By default the progress bar is at the top and the message at the bottom. This can be flipped around if so desired.

bar_on_bottom

Styling changes

const int totalTicks = 10;
var options = new ProgressBarOptions
{
	ForegroundColor = ConsoleColor.Yellow,
	ForegroundColorDone = ConsoleColor.DarkGreen,
	BackgroundColor = ConsoleColor.DarkGray,
	BackgroundCharacter = '\u2593'
};
using (var pbar = new ProgressBar(totalTicks, "showing off styling", options))
{
	TickToCompletion(pbar, totalTicks, sleep: 500);
}

Many aspects can be styled including foreground color, background (inactive portion) and changing the color on completion.

styling

No real time update

By default a timer will draw the screen every 500ms. You can configure the progressbar to only be drawn when .Tick() is called.

const int totalTicks = 5;
var options = new ProgressBarOptions
{
	DisplayTimeInRealTime = false
};
using (var pbar = new ProgressBar(totalTicks, "only draw progress on tick", options))
{
	TickToCompletion(pbar, totalTicks, sleep:1750);
}

If you look at the time passed you will see it skips 02:00

update_on_tick

Descendant progressbars

A progressbar can spawn child progress bars and each child can spawn its own progressbars. Each child can have its own styling options.

This is great to visualize concurrent running tasks.

const int totalTicks = 10;
var options = new ProgressBarOptions
{
	ForegroundColor = ConsoleColor.Yellow,
	BackgroundColor = ConsoleColor.DarkYellow,
	ProgressCharacter = '─'
};
var childOptions = new ProgressBarOptions
{
	ForegroundColor = ConsoleColor.Green,
	BackgroundColor = ConsoleColor.DarkGreen,
	ProgressCharacter = '─'
};
using (var pbar = new ProgressBar(totalTicks, "main progressbar", options))
{
	TickToCompletion(pbar, totalTicks, sleep: 10, childAction: () =>
	{
		using (var child = pbar.Spawn(totalTicks, "child actions", childOptions))
		{
			TickToCompletion(child, totalTicks, sleep: 100);
		}
	});
}

children

By default children will collapse when done, making room for new/concurrent progressbars.

You can keep them around by specifying CollapseWhenFinished = false

var childOptions = new ProgressBarOptions
{
	ForegroundColor = ConsoleColor.Green,
	BackgroundColor = ConsoleColor.DarkGreen,
	ProgressCharacter = '─',
	CollapseWhenFinished = false
};

children_no_collapse

Credits

The initial implementation was inspired by this article. http://www.bytechaser.com/en/articles/ckcwh8nsyt/display-progress-bar-in-console-application-in-c.aspx

And obviously anyone who sends a PR to this repository 👍

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 netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net46 was computed.  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 tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 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.

NuGet packages (14)

Showing the top 5 NuGet packages that depend on ShellProgressBar:

Package Downloads
TIKSN-Framework

This is a .NET Framework enhancement framework. Main features are Versioning, Finance, Currency, Foreign Exchange, Money, Pricing strategy, Telemetry, Composite Weighted Progress, Repository and Unity of Wok pattern implementation with Entity Framework Core, Network Connectivity Service and Triggering, Settings, Windows Registry configuration source, Azure Storage Repository, MongoDB Repository, NoDB Repository, Lingual and Regional Localization, Serialization, Rest Requester, Rest Repository, Dependency Injection, Composition Root Setup base classes.

Microsoft.CST.ApplicationInspector.Commands

Microsoft Application Inspector is a software source code analysis tool that helps identify and surface well-known features and other interesting characteristics of source code to aid in determining what the software is or what it does.

stryker

All stryker mutation test logic is contained in this library. This package does not include a runner. Use this package if you want to extend stryker with your own runner.

Chiron.Cli.Lab

Lab Chiron CLI components.

Catalyst.Tools.Importer

Package Description

GitHub repositories (13)

Showing the top 5 popular GitHub repositories that depend on ShellProgressBar:

Repository Stars
microsoft/ApplicationInspector
A source code analyzer built for surfacing features of interest and other characteristics to answer the question 'What's in the code?' quickly using static analysis with a json based rules engine. Ideal for scanning components before use or detecting feature level changes.
stryker-mutator/stryker-net
Mutation testing for .NET core and .NET framework!
bezzad/Downloader
Fast, cross-platform and reliable multipart downloader with asynchronous progress events for .NET applications.
takuya-takeuchi/FaceRecognitionDotNet
The world's simplest facial recognition api for .NET on Windows, MacOS and Linux
Reloaded-Project/Reloaded-II
Universal .NET Core Powered Modding Framework for any Native Game X86, X64.
Version Downloads Last updated
5.2.0 603,055 6/7/2022
5.1.0 731,868 1/29/2021
5.0.0 552,189 2/23/2020
4.3.0 213,242 8/20/2019
4.2.0 229,626 8/25/2018
4.1.1 6,237 8/15/2018
4.0.0 52,988 11/12/2017
3.0.0 139,770 4/11/2016
1.2.0 21,078 8/26/2015
1.1.0 13,912 6/19/2014
1.0.0 11,889 11/14/2013