depot/packages/networking/hyprspace/cli/root.go
Max 9954f8eb03 packages/hyprspace: 0.7.1 -> 0.8.0
- config overhaul
- remove unnecessary cli args
- remove down command
2023-10-27 00:32:18 +02:00

65 lines
1.2 KiB
Go

package cli
import (
"fmt"
"log"
"sync"
"time"
"github.com/DataDrake/cli-ng/v2/cmd"
)
var appVersion string = "develop"
// GlobalFlags contains the flags for commands.
type GlobalFlags struct {
Config string `short:"c" long:"config" desc:"Specify a custom config path."`
InterfaceName string `short:"i" long:"interface" desc:"Interface name."`
}
// Root is the main command.
var Root *cmd.Root
func init() {
Root = &cmd.Root{
Name: "hyprspace",
Short: "Hyprspace Distributed Network",
Version: appVersion,
Flags: &GlobalFlags{},
}
cmd.Register(&cmd.Help)
cmd.Register(&Init)
cmd.Register(&Up)
cmd.Register(&Status)
cmd.Register(&Peers)
cmd.Register(&Route)
cmd.Register(&cmd.Version)
}
func checkErr(err error) {
if err != nil {
log.Fatal(err)
}
}
// Spinner is an array of the progression of the spinner.
var Spinner = []string{"|", "/", "-", "\\"}
// SpinnerWait displays the actual spinner
func SpinnerWait(done chan int, message string, wg *sync.WaitGroup) {
ticker := time.NewTicker(time.Millisecond * 128)
frameCounter := 0
for {
select {
case <-done:
wg.Done()
return
default:
<-ticker.C
ind := frameCounter % len(Spinner)
fmt.Printf("\r[%v] "+message, Spinner[ind])
frameCounter++
}
}
}