linsk/cmd/build.go
2023-08-31 20:10:26 +01:00

30 lines
751 B
Go

package cmd
import (
"log/slog"
"os"
"github.com/spf13/cobra"
)
var buildCmd = &cobra.Command{
Use: "build",
Short: "Build (set up) a VM image for local use. This needs to be run after the initial installation.",
Run: func(cmd *cobra.Command, args []string) {
store := createStoreOrExit()
err := store.BuildVMImageWithInterruptHandler(vmDebugFlag, buildOverwriteFlag)
if err != nil {
slog.Error("Failed to build VM image", "error", err.Error())
os.Exit(1)
}
slog.Info("VM image built successfully", "path", store.GetVMImagePath())
},
}
var buildOverwriteFlag bool
func init() {
buildCmd.Flags().BoolVar(&buildOverwriteFlag, "overwrite", false, "Specifies whether the VM image should be overwritten with the build.")
}