Reduce main func complexity
This commit is contained in:
parent
18a92703ba
commit
d42474892c
21
main.go
21
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") {
|
||||
|
Loading…
Reference in New Issue
Block a user