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
|
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"} {
|
if err != nil {
|
||||||
_, err := exec.Command("which", cmd).CombinedOutput()
|
log.Fatalln(err)
|
||||||
if err != nil {
|
|
||||||
log.Fatalln("Command not found:", cmd)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !exists(usr.HomeDir + "/.out-of-tree/images") {
|
if !exists(usr.HomeDir + "/.out-of-tree/images") {
|
||||||
|
Loading…
Reference in New Issue
Block a user