fhelp/linux.go

35 lines
632 B
Go

package fhelp
// auto run protoc with the correct args
import (
"bufio"
"fmt"
"os"
"strings"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
func linuxInstall(pkg string) {
cmd := []string{"apt", "install", "-y", pkg}
if pkg == "protoc" {
cmd = []string{"apt", "install", "-y", "protobuf-compiler"}
}
log.Info("Would you like to run", "sudo", cmd, "now?")
fmt.Fprintf(os.Stdout, "(y)es or (n)o ? ")
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
line := scanner.Text()
line = strings.TrimSpace(line)
line = strings.ToLower(line)
switch line {
case "y":
shell.Sudo(cmd)
default:
}
}
}