https://github.com/bharath-srinivas/termloader
A simple Go library for implementing terminal loading screen
https://github.com/bharath-srinivas/termloader
go golang loading-animations loading-screen loadingscreen terminal terminal-based
Last synced: about 1 month ago
JSON representation
A simple Go library for implementing terminal loading screen
- Host: GitHub
- URL: https://github.com/bharath-srinivas/termloader
- Owner: bharath-srinivas
- License: mit
- Created: 2018-03-21T16:49:17.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-10-09T04:17:42.000Z (over 2 years ago)
- Last Synced: 2025-08-15T09:58:37.311Z (7 months ago)
- Topics: go, golang, loading-animations, loading-screen, loadingscreen, terminal, terminal-based
- Language: Go
- Size: 6.36 MB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Termloader
[](https://circleci.com/gh/bharath-srinivas/termloader/?branch=master)
[](https://godoc.org/github.com/bharath-srinivas/termloader)
[](LICENSE)
Termloader is a simple library to add a loading screen to your terminal applications. Termloader will render the
loader at the center of your terminal screen. Currently termloader is supported only on *nix operating systems.
## Installation
```bash
go get github.com/bharath-srinivas/termloader
```
## Example Usage
```go
package main
import (
"time"
"github.com/bharath-srinivas/termloader"
)
func main() {
loader := termloader.New(termloader.CharsetConfigs["default"]) // construct a new loader with config
loader.Start() // start the loader
time.Sleep(5 * time.Second) // sleep for sometime to simulate a task
loader.Stop() // stop the loader
}
```
## Loader color
```go
loader.Color = termloader.Green // provide a color for the loader (white if not provided)
```
## Provide a loading text
```go
loader.Text = "Loading" // provide a text to show above the loader
```
## Loading text color
```go
loadingText := termloader.ColorString("Now Loading", termloader.Green) // color the string
loader.Text = loadingText // provide the colored string as loading text
```
## Custom delay
```go
loader.Delay = 100 * time.Millisecond // delay in milliseconds
```
## Loading image
Termloader supports only `jpeg` and `png` formats as of now. Support for more formats might be added later.
```go
loader.Image.SetPath("/path/to/image") // provide the path of the loading image
loader.Image.SetWidth(55) // set custom width for the image
loader.Image.SetHeight(15) // set custom height for the image
loader.Image.Sharpen(6.5) // sharpens the image
```
## Provide your own character set for loader
```go
charsetConfig := termloader.CharsetConfig{Charset: []string{"|", "/", "-", "\\"}, Delay: 100 * time.Millisecond}
loader := termloader.New(charsetConfig)
```
## Todo
- [x] Loader
- [x] Optional loading text support
- [x] Optional image/icon support
- [x] Add a gif
## License
MIT