A README.md => README.md +14 -0
@@ 0,0 1,14 @@
+# go-indicators
+
+[](https://pkg.go.dev/gitlab.com/poldi1405/go-indicators)
+
+go-indicators allows to easily create status and progress-indicators.
+
+## Example
+
+You can run an example of what it can look like by executing
+
+```
+go get gitlab.com/poldi1405/go-indicators
+go run gitlab.com/poldi1405/go-indicators
+```
A progress/doc.go => progress/doc.go +3 -0
@@ 0,0 1,3 @@
+// Package progress allows easily creating progressbars with multiple
+// intermediary stages, like UTF-8 blocks.
+package progress
A spinner/README.md => spinner/README.md +3 -0
@@ 0,0 1,3 @@
+# spinner
+
+Spinner allows creating simple or complex spinners. See godocs for more.
A spinner/doc.go => spinner/doc.go +3 -0
@@ 0,0 1,3 @@
+// Package spinner allows creating and using spinners that indicate that a
+// process is working in the background.
+package spinner
A spinner/doc_test.go => spinner/doc_test.go +34 -0
@@ 0,0 1,34 @@
+package spinner
+
+import (
+ "fmt"
+ "time"
+)
+
+// This function pretty much shows all you need for using a spinner:
+// 1. create a spinner
+// 2. set a style
+// 3. use .Next()
+func Example_SimpleSpinner() {
+ var s Spinner
+ s.SetStyle("dots")
+
+ for i := 0; i < 100; i++ {
+ fmt.Printf("\rworking%v", s.Next())
+ time.Sleep(80 * time.Millisecond)
+ }
+}
+
+// This shows the same spinner 3 times and cleans up afterwards
+func Example_Multiuse() {
+ var s1 Spinner
+ s1.SetStyle("bouncing-bar")
+
+ for i := 0; i < 100; i++ {
+ fmt.Printf(" %v\tdo stuff\n %v\texecuting something else\n %v\twaiting for some seconds\r\033[F\033[F", s1.Next(), s1.Current(), s1.Current())
+ time.Sleep(80 * time.Millisecond)
+ }
+
+ // removes the spinner-characters but leaves the text untouched
+ fmt.Printf(" %v\n %v\n %v\n", s1.Clear(), s1.Clear(), s1.Clear())
+}