package main

import (
	"flag"

	"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 == "" {
		fatalf("--node is required")
	}
	if *boot == "" && *root == "" {
		fatalf("--boot or --root is required")
	}
	inv := loadInventory(*invPath)
	if err := plan.Inject(inv, *node, *boot, *root); err != nil {
		fatalf("inject: %v", err)
	}
}
