diff --git a/main.go b/main.go index f71d9c2..896a971 100644 --- a/main.go +++ b/main.go @@ -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() - if err != nil { - log.Fatalln("Command not found:", cmd) - } + err = checkRequiredUtils() + if err != nil { + log.Fatalln(err) } if !exists(usr.HomeDir + "/.out-of-tree/images") {