spinners
is a cross-platform V library written in C and V to create spinner animations in your terminal. Useful for creating CLIs in V. Sample output:
With the default v cli:
v install --git https://github.com/rhygg/spinners
or with vpkg:
vpkg get spinners
import spinners { Spinner }
import time
fn main() {
mut sp := Spinner{}
sp.start("please wait...") ?
time.sleep(1000 * time.millisecond)
sp.stop()
println("done!")
}
import spinners { Spinner, AnimationType }
import time
fn main() {
mut sp := Spinner {
animation: AnimationType.simple_dots
}
sp.start("please wait...") ?
time.sleep(3000 * time.millisecond)
// you can change text while it's running!
sp.set_text("almost there! hang tight...")
time.sleep(1000 * time.millisecond)
sp.stop()
println("done!")
}
import spinners { Spinner }
import time
fn main() {
mut sp := Spinner {
frames: [ 'a', 'b', 'c', 'd' ] // string length must be consistent
interval: 80 // in ms
}
sp.start("please wait...") ?
time.sleep(1000 * time.millisecond)
sp.stop()
println("done!")
}
import spinners { Spinner, Color }
import time
fn main() {
mut sp := Spinner {
color: Color.magenta
}
sp.start("please wait...")
time.sleep(1000 * time.millisecond)
sp.stop()
println("done!")
}
import spinners { Spinner, Color }
import time
fn main() {
mut sp := Spinner {
color: Color.magenta
}
sp.start("please wait...") ?
time.sleep(1000 * time.millisecond)
// instead of stop we can use success, warning, error, or info.
// sends a success message
sp.success("done!")
// sends an error message
sp.error("error!")
// sends a warning message
sp.warning("warning!")
// sends a info message
sp.info("info!")
}