package main

import (
	"flag"
	"log"

	"metis/pkg/plan"
)

func injectCmd(args []string) {
	fs := flag.NewFlagSet("inject", flag.ExitOnError)
	invPath := fs.String("inventory", "inventory.yaml", "inventory file")
	node := fs.String("node", "", "target node")
	boot := fs.String("boot", "", "mounted boot path")
	root := fs.String("root", "", "mounted root path")
	fs.Parse(args)
	if *node == "" {
		log.Fatalf("--node is required")
	}
	if *boot == "" && *root == "" {
		log.Fatalf("--boot or --root is required")
	}
	inv := loadInventory(*invPath)
	if err := plan.Inject(inv, *node, *boot, *root); err != nil {
		log.Fatalf("inject: %v", err)
	}
}
