package main

import (
    "encoding/json"
    "flag"
    "log"
    "os"

    "metis/pkg/config"
)

func configCmd(args []string) {
    fs := flag.NewFlagSet("config", flag.ExitOnError)
    invPath := fs.String("inventory", "inventory.yaml", "inventory file")
    node := fs.String("node", "", "target node")
    fs.Parse(args)
    if *node == "" {
        log.Fatalf("--node is required")
    }
    inv := loadInventory(*invPath)
    cfg, err := config.Build(inv, *node)
    if err != nil {
        log.Fatalf("config build: %v", err)
    }
    enc := json.NewEncoder(os.Stdout)
    enc.SetIndent("", "  ")
    _ = enc.Encode(cfg)
}
