<commit_before># Building a command-line tool with progress bar in .NET Core

##### <NAME>, February 6, 2018

Command-line tools can be a great utility for automation of repetitive tasks, which makes it a powerful tool for the super-user. Enhancements like a progress bar make it more user friendly and gives the user an insight into what’s happening. A second enhancement or rather a choice is to build command-line tools in .NET Core, which ensures every user can use it, no matter whether they use Mac, Linux or Windows. This blog post will show how to set up a command-line tool which accepts arguments and show how to implement the ShellProgressBar-package that enables the use of progress bars.

You first need a Console App for .NET Core. You can create a new one in Visual Studio with ease and you will then be ready to get started.

![Create console app](/images/create_net_core_console_app.png)

You need two packages for the project which both can be added via NuGet. The first one is [Microsoft.Extensions.CommandlineUtils](https://www.nuget.org/packages/Microsoft.Extensions.CommandLineUtils/). It enables the application to handle the arguments given to it, which will be elaborated on further below. The second package is [ShellProgressBar](https://www.nuget.org/packages/ShellProgressBar/), which is created by Mpdreamz. This gives us an easy tool for displaying a progress bar.

We have created a fictional task, which is to create a group of files containing hash codes for some strings, to guide you through the different types of options. To start, we go to our program's main method that gets the arguments on start.  We then initialize a new `CommandLineApplication` object and set its description, etc.

```csharp
var app = new CommandLineApplication();<commit_msg>Header info to new blog post<commit_after>---
description: Tutorial on building a command line tool with progress bar in .NET, using the Microsoft.Extensions.CommandLineUtils and ShellProgressBar NuGet packages. Building a command line tool using .NET Core makes it possible to execute it on both Windows, Linux and Mac.
image: images/create_net_core_console_app.png
booksignup: true
---

 # Building a command-line tool with progress bar in .NET Core

##### <NAME>, February 6, 2018

Command-line tools can be a great utility for automation of repetitive tasks, which makes it a powerful tool for the super-user. Enhancements like a progress bar make it more user friendly and gives the user an insight into what’s happening. A second enhancement or rather a choice is to build command-line tools in .NET Core, which ensures every user can use it, no matter whether they use Mac, Linux or Windows. This blog post will show how to set up a command-line tool which accepts arguments and show how to implement the ShellProgressBar-package that enables the use of progress bars.

You first need a Console App for .NET Core. You can create a new one in Visual Studio with ease and you will then be ready to get started.

![Create console app](/images/create_net_core_console_app.png)

You need two packages for the project which both can be added via NuGet. The first one is [Microsoft.Extensions.CommandlineUtils](https://www.nuget.org/packages/Microsoft.Extensions.CommandLineUtils/). It enables the application to handle the arguments given to it, which will be elaborated on further below. The second package is [ShellProgressBar](https://www.nuget.org/packages/ShellProgressBar/), which is created by Mpdreamz. This gives us an easy tool for displaying a progress bar.

We have created a fictional task, which is to create a group of files containing hash codes for some strings, to guide you through the different types of options. To start, we go to our program's main method that gets the arguments on start.  We then initialize a new `CommandLineApplication` object and set its description, etc.

```csharp
var app = new CommandLineApplication();
{'fraction_non_alphanumeric': 0.05204366590505204, 'fraction_numerical': 0.002538715410002539, 'mean_word_length': 4.580736543909349, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7660312', 'n_tokens_mistral': 955, 'n_tokens_neox': 923, 'n_words': 580}