1
0
Fork 0

Reduce main func complexity

timestamps
dump_stack() 2018-12-10 02:51:15 +00:00
parent 18a92703ba
commit d42474892c
1 changed files with 15 additions and 6 deletions

19
main.go
View File

@ -5,6 +5,7 @@
package main
import (
"fmt"
"log"
"os"
"os/exec"
@ -49,6 +50,17 @@ func handleFallbacks(kcfg config.KernelConfig) {
}
}
func checkRequiredUtils() (err error) {
// Check for required commands
for _, cmd := range []string{"docker", "qemu-system-x86_64"} {
_, err := exec.Command("which", cmd).CombinedOutput()
if err != nil {
return fmt.Errorf("Command not found: %s", cmd)
}
}
return
}
func main() {
app := kingpin.New(
"out-of-tree",
@ -123,12 +135,9 @@ func main() {
bootstrapCommand := app.Command("bootstrap",
"Create directories && download images")
// Check for required commands
for _, cmd := range []string{"docker", "qemu-system-x86_64"} {
_, err := exec.Command("which", cmd).CombinedOutput()
err = checkRequiredUtils()
if err != nil {
log.Fatalln("Command not found:", cmd)
}
log.Fatalln(err)
}
if !exists(usr.HomeDir + "/.out-of-tree/images") {