• Stars
    star
    656
  • Rank 68,675 (Top 2 %)
  • Language
    C#
  • License
    MIT License
  • Created almost 7 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Terminal Spinner for .NET platform

Kurukuru

Build-Development

Terminal Spinner library for .NET platform (.NET Framework, .NET Standard, .NET 5). strongly inspired by cli-spinners, ora, CLISpinner.

Features

Aware non-Unicode codepage on Windows environment.

When running on terminal using non-Unicode codepages (e.g. CP437:EN-US, CP932:JA-JP), the library will render using ASCII-characters spinner by default.

  • fig. Left:Command Prompt (CP932) / Right:mintty (UTF-8 on Linux)

NOTE: Sadly, today's almost Windows are configured as using non-Unicode (UTF-8) code page and "Command Prompt" doesn't support font fallback yet. If you want to see non-ASCII spinners, you can change the code page either by System.Console.OutputEncoding = System.Text.Encoding.UTF8 or by running chcp 65001 command and then use ConEmu or mintty to display the fallback font.

Disable spinner automatically when running on a non-interactive context in which stdout is redirected.

For example, you can see just a result text when runs on CI.

Install

Package Manager Console

Install-Package Kurukuru

dotnet command

dotnet add package Kurukuru

Usage

Just add using Kurukuru; then call Spinner.Start with some delegate.

Spinner.Start("Processing...", () =>
{
    Thread.Sleep(1000 * 3);
    
    // MEMO: If you want to show as failed, throw a exception here.
    // throw new Exception("Something went wrong!");
});

Spinner.Start("Stage 1...", spinner =>
{
    Thread.Sleep(1000 * 3);
    spinner.Text = "Stage 2...";
    Thread.Sleep(1000 * 3);
    spinner.Fail("Something went wrong!");
});

You can also use async method pattern. Use StartAsync method.

await Spinner.StartAsync("Processing...", async () =>
{
    await Task.Delay(1000 * 3);
    
    // MEMO: If you want to show as failed, throw a exception here.
    // throw new Exception("Something went wrong!");
});

await Spinner.StartAsync("Stage 1...", async spinner =>
{
    await Task.Delay(1000 * 3);
    spinner.Text = "Stage 2...";
    await Task.Delay(1000 * 3);
    spinner.Fail("Something went wrong!");
});

API

Kurukuru.Spinner class

Static Members

  • Start / StartAsync: Create and start new spinner. And it waits specified action.
    • void Start(string text, Action<Spinner> action, Pattern pattern = null, Pattern fallbackPattern = null)
    • void Start(string text, Action<Spinner> action, Pattern pattern = null, Pattern fallbackPattern = null)
    • Task StartAsync(string text, Func<Task> action, Pattern pattern = null, Pattern fallbackPattern = null)
    • Task StartAsync(string text, Func<Spinner, Task> action, Pattern pattern = null, Pattern fallbackPattern = null)
      • text: a text to display while running action.
      • action: a long-running action.
      • patterns: Use spinner pattern (see Patterns class). Default value is Patterns.Dot. You can find a pattern you like in the preview of cli-spinners.
      • fallbackPattern: Use spinner pattern if console's codepage is non-Unicode. Default value is Patterns.Line.

Instance Methods

  • Stop: Stop spinner and show a result if needed.
    • Stop(string text = null, string symbol = null, ConsoleColor? color = null)
    • Stop(string text, string symbol, ConsoleColor? color, string terminator)
  • Success: Show result as success. (equivalent to Stop method)
  • Fail: Show result as failure. (equivalent to Stop method)
  • Warning: Show result as warning. (equivalent to Stop method)
  • Info: Show result as information. (equivalent to Stop method)

Instance Properties

  • Text: Get or set a text to display while running action.
  • Color: Get or set a color of the spinner. (not for text)

Related

  • cli-spinners: Spinners for use in the terminal (node.js)
  • ora: Elegant terminal spinner (node.js)
  • CLISpinner: Swifty Terminal Spinner

License

MIT License.

More Repositories

1

Cocona

Micro-framework for .NET console application. Cocona makes it easy and fast to build console applications on .NET.
C#
3,209
star
2

Rin

Request/response Inspector middleware for ASP.NET Core
C#
643
star
3

Chell

Write scripts with the power of C# and .NET
C#
75
star
4

Beatrice

Everything is a smart home device works with Google Home/Assistant.
C#
66
star
5

WeekRef.NET

WeekRef.NET: 週刊 .NET
JavaScript
59
star
6

PlatformStatusTracker

Tracker for the Web browser platform statuses
C#
41
star
7

ChatworkExtension

ChatWorkを改造します
JavaScript
37
star
8

Qulaly

A library that queries Roslyn's C# syntax tree with CSS selector-like syntax.
C#
30
star
9

Inazuma

Minimal CLR Implementation (MSIL Interpreter) for .NET Framework. Nanodesu!
C#
25
star
10

AppleWirelessKeyboardHelper

C#
22
star
11

Yafp

A toolkit for implementing forward proxy based on ASP.NET Core and YARP.
C#
18
star
12

BraviaControl

Sony BRAVIA remote control API client for .NET
C#
17
star
13

dotnet-sail

Downloads .NET project from Gist, GitHub, Git, or the web and runs it in a container.
C#
14
star
14

Kanae

Kanae - Private Gyazo server written in C# + ASP.NET
JavaScript
12
star
15

Cartelet

.NET Framework向けHTMLパーサー/フィルターライブラリ
C#
11
star
16

SourceGeneratorPlayground

Templates for playing with Source Generator.
C#
10
star
17

Mimosa

Syntax highlighter built with Monaco Editor (Visual Studio Code)
JavaScript
8
star
18

JsonStreamLogger

JSON Stream logger provider implementation for Microsoft.Extensions.Logging.
C#
8
star
19

Pripod

Pripod enables you to easily access Pod information from the .NET app inside a Pod.
C#
8
star
20

AgqrPlayer4Tv

超A&G+をAndroid TVで再生するための雑なアプリ
Kotlin
7
star
21

LetterWriter

Unity向けの日本語テキスト表示ライブラリ
C#
7
star
22

aircvw

Tiarra IRC Log Viewer (Aircvw: えあくぎゅう)
JavaScript
7
star
23

KumoDictionary

IDictionary<TKey, TValue> in the Cloud - Simple NoSQL/KVS wrapper for .NET
C#
6
star
24

Downwrite

Markdown Editor for Metro style apps
JavaScript
5
star
25

SimpleBasicAuthenticationModule

Simple Basic Authentication Module for IIS/ASP.NET
C#
5
star
26

Sample.MonoCecil

C#
5
star
27

Backlog

Backlog API for .NET
C#
4
star
28

MraaSharp

.NET(C#, Mono) binding/wrapper for Intel MRAA library
C#
4
star
29

VistaFace.gadget

JavaScript
4
star
30

KssSharp

A .NET Framework (C#) Implementation of KSS: A methodology for documenting CSS and generating styleguides
C#
3
star
31

Metrica

IRC Client for Metro style apps
JavaScript
3
star
32

Iroha

コンポーネントエディタみたいな何かとASP.NET Web Pagesを吐き出すCMSみたいな何か。
JavaScript
3
star
33

RadioWhip

フィードがないページのフィードを作るアレ
C#
2
star
34

mayuki.github.com

mayuki.github.com
HTML
2
star
35

ThumbSense4Surface

ThumbSense for Surface Pro
C#
2
star
36

SimpleAspNetWebHost

C#
2
star
37

MyPlaceholder

A clone of "placehold.it" / ASP.NET MVC
C#
2
star
38

WatchDotNetGitHubRepos

C#
2
star
39

UniCorefx

.NET 4 BCL の一部 for Unityっぽい
C#
2
star
40

IndentAutoConfigurator

Visual Studio 2012でファイルごとにインデントの設定を自動で切り替える拡張
C#
2
star
41

ViewTgaInGitHub

Enable viewing for TARGA format in GitHub
JavaScript
1
star
42

Samidare

File based blog/page engine for ASP.NET Web Pages
C#
1
star
43

HyperEstraierBinding

HyperEstraier Binding for .NET Framework (C#)
C#
1
star
44

ClassicCgiApp

古き良きCGIアプリっぽいものをASP.NET Coreで再現する
C#
1
star
45

Madosta-20160521-Demo

C#
1
star
46

Mvc4Samples

JavaScript
1
star
47

SassTray

Sass コマンドを実行しつつ通知領域にしまわれるようにするためのアレ。
C#
1
star
48

Cod2013

Community Open Day 2013
JavaScript
1
star
49

DockIconPreviewer

Dock Icon Previewer
1
star