/spinnercpp

Simple header only library to add a spinner / progress indicator to any terminal application.

Primary LanguageC++MIT LicenseMIT

spinnercpp

spinnercpp is a simple header only library to add a spinner / progress indicator to any terminal application. spinnercpp is based on [https://github.com/briandowns/spinner]

Contributions welcome!

https://1.bp.blogspot.com/-dUjJ_XFIx8c/XZeajOvE7AI/AAAAAAAAF94/r7RJrJDfEs4ybrIPipTHgTFIUykfgUciwCLcBGAsYHQ/s1600/spinners.png

Features

  • Start
  • Stop
  • Restart
  • Update the spinner speed
  • Prefix or append text
  • Output final string on spinner/indicator completion

Examples

Simple use

#include "../../spinnercpp.h"

int main() {
  auto spin = std::make_unique<spinnercpp::spinner>();
  spin->start();
  std::this_thread::sleep_for(std::chrono::milliseconds(3000)); 
  
  return 0;
}

Stop

#include <iostream>
#include "../../spinnercpp.h"

using namespace std;

int main() {
  auto spin = std::make_unique<spinnercpp::spinner>();
  spin->start();
  std::this_thread::sleep_for(std::chrono::milliseconds(3000)); 
  spin->stop();

  cout << "Stop" << endl;
  
  return 0;
}

Update spin speed and restart the spinner

auto spin = std::make_unique<spinnercpp::spinner>(100ms);
spin->start();

Choose the spinner

To use the charset 10

auto spin = std::make_unique<spinnercpp::spinner>(100ms, 10); 
spin->start();

Preffix and Suffix

auto spin = std::make_unique<spinnercpp::spinner>(100ms, 10, "> ", " |"); 
spin->start();