mirror of
https://code.dumpstack.io/tools/appvm.git
synced 2024-11-24 00:51:38 +00:00
Add progress bar
This commit is contained in:
parent
36267ac5ea
commit
326b9ce610
14
appvm.go
14
appvm.go
|
@ -17,6 +17,7 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -224,6 +225,18 @@ func generateAppVM(l *libvirt.Libvirt, appvmPath, name string) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stupidProgressBar() {
|
||||||
|
const length = 70
|
||||||
|
for {
|
||||||
|
time.Sleep(time.Second / 4)
|
||||||
|
fmt.Printf("\r%s]\r[", strings.Repeat(" ", length))
|
||||||
|
for i := 0; i <= length-2; i++ {
|
||||||
|
time.Sleep(time.Second / 20)
|
||||||
|
fmt.Printf("+")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func start(l *libvirt.Libvirt, name string) {
|
func start(l *libvirt.Libvirt, name string) {
|
||||||
// Currently binary-only installation is not supported, because we need *.nix configurations
|
// Currently binary-only installation is not supported, because we need *.nix configurations
|
||||||
appvmPath := os.Getenv("GOPATH") + "/src/github.com/jollheef/appvm"
|
appvmPath := os.Getenv("GOPATH") + "/src/github.com/jollheef/appvm"
|
||||||
|
@ -235,6 +248,7 @@ func start(l *libvirt.Libvirt, name string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isRunning(l, name) {
|
if !isRunning(l, name) {
|
||||||
|
go stupidProgressBar()
|
||||||
err = generateAppVM(l, appvmPath, name)
|
err = generateAppVM(l, appvmPath, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
Loading…
Reference in a new issue