![]() |
VOOZH | about |
dotnet add package ShellProgressBar --version 5.2.0
NuGet\Install-Package ShellProgressBar -Version 5.2.0
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
<PackageVersion Include="ShellProgressBar" Version="5.2.0" />Directory.Packages.props
<PackageReference Include="ShellProgressBar" />Project file
paket add ShellProgressBar --version 5.2.0
#r "nuget: ShellProgressBar, 5.2.0"
#:package ShellProgressBar@5.2.0
#addin nuget:?package=ShellProgressBar&version=5.2.0Install as a Cake Addin
#tool nuget:?package=ShellProgressBar&version=5.2.0Install as a Cake Tool
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
and Windows
(Powershell works too, see example further down)
Get it on nuget: http://www.nuget.org/packages/ShellProgressBar/
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");
}
There are two ways to report progression. You can use the Tick() function as described above. Alternatively you can report progression through an IProgress<T> instance that you obtain by calling AsProgress<T>() on the progress bar object.
For a simple case where the progress type is a float value between 0.0 and 1.0 that represents the completion percentage, use progressBar.AsProgress<float>():
using ProgressBar progressBar = new ProgressBar(10000, "My Progress Message");
IProgress progress = progressBar.AsProgress<float>();
progress.Report(0.25); // Advances the progress bar to 25%
See IntegrationWithIProgressExample.cs and IntegrationWithIProgressPercentageExample.cs in the directory for full examples.
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.
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.
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
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);
}
});
}
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
};
ProgressBar is great for visualizing tasks with an unknown runtime. If you have a task that you know takes a fixed amount of time there is also a FixedDurationBar subclass.
FixedDurationBar will Tick() automatically but other then that all the options and usage are the same. Except it relies on the real time update feature so disabling that
will throw.
FixedDurationBar exposes an IsCompleted and CompletedHandle
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp1.0 netcoreapp1.0 was computed. netcoreapp1.1 netcoreapp1.1 was computed. netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard1.3 netstandard1.3 is compatible. netstandard1.4 netstandard1.4 was computed. netstandard1.5 netstandard1.5 was computed. netstandard1.6 netstandard1.6 was computed. netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net46 net46 was computed. net461 net461 is compatible. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen30 tizen30 was computed. tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Universal Windows Platform | uap uap was computed. uap10.0 uap10.0 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on ShellProgressBar:
| Package | Downloads |
|---|---|
|
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. |
|
|
Catalyst.Tools.Importer
Package Description |
|
|
Chiron.Cli.Lab
Lab Chiron CLI components. |
|
|
ConsoleStyle
Package Description |
Showing the top 12 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. If you want Downloader Desktop application see this: https://github.com/bezzad/downloader.desktop
|
|
|
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.
|
|
|
VedAstro/VedAstro
A non-profit, open source project to make Vedic Astrology easily available to all.
|
|
|
planetarium/NineChronicles
Unity client application for Nine Chronicles, a fully decentralized idle RPG powered by the community.
|
|
|
CmlLib/CmlLib.Core
.NET Minecraft Launcher Library. All Version, Auth, Forge, Java, Crossplatform
|
|
|
philipmat/discogs-xml2db
Imports the discogs.com monthly XML dumps into databases
|
|
|
nullpainter/sanchez
False-colour geostationary satellite image compositor
|
|
|
opensearch-project/opensearch-net
OpenSearch .NET Client
|
|
| hahagu/WindowsThumbnailGenerator |