1
0

Reduce main func complexity

This commit is contained in:
dump_stack() 2018-12-10 02:51:15 +00:00
parent 18a92703ba
commit d42474892c

19
main.go
View File

@ -5,6 +5,7 @@
package main package main
import ( import (
"fmt"
"log" "log"
"os" "os"
"os/exec" "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() { func main() {
app := kingpin.New( app := kingpin.New(
"out-of-tree", "out-of-tree",
@ -123,12 +135,9 @@ func main() {
bootstrapCommand := app.Command("bootstrap", bootstrapCommand := app.Command("bootstrap",
"Create directories && download images") "Create directories && download images")
// Check for required commands err = checkRequiredUtils()
for _, cmd := range []string{"docker", "qemu-system-x86_64"} {
_, err := exec.Command("which", cmd).CombinedOutput()
if err != nil { if err != nil {
log.Fatalln("Command not found:", cmd) log.Fatalln(err)
}
} }
if !exists(usr.HomeDir + "/.out-of-tree/images") { if !exists(usr.HomeDir + "/.out-of-tree/images") {