88 lines
2.4 KiB
Go
Executable File
88 lines
2.4 KiB
Go
Executable File
// Package main is the cauldron CLI — the Blacksmith of the Coven.
|
|
//
|
|
// Usage:
|
|
// cauldron build <image.yaml> Compose an ISO from a manifest
|
|
// cauldron portable <spell> --target arch Forge a static ELF for the Portable Bin
|
|
// cauldron emergency-kit Forge the curated recovery bundle
|
|
// cauldron list Show all generated images
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) < 2 {
|
|
usage()
|
|
os.Exit(1)
|
|
}
|
|
switch os.Args[1] {
|
|
case "build":
|
|
buildImage(os.Args[2:])
|
|
case "portable":
|
|
portable(os.Args[2:])
|
|
case "emergency-kit":
|
|
emergencyKit(os.Args[2:])
|
|
case "list":
|
|
listImages()
|
|
case "help", "-h", "--help":
|
|
usage()
|
|
default:
|
|
fmt.Fprintf(os.Stderr, "unknown subcommand: %s\n", os.Args[1])
|
|
os.Exit(2)
|
|
}
|
|
}
|
|
|
|
func usage() {
|
|
fmt.Print(`cauldron — the Blacksmith of the Coven
|
|
|
|
Usage:
|
|
cauldron build <image.yaml> [--format iso|tar|qcow2]
|
|
cauldron portable <spell> --target <arch> [--essence-out path]
|
|
cauldron emergency-kit [--bundle out.svb]
|
|
cauldron list
|
|
`)
|
|
}
|
|
|
|
func buildImage(args []string) {
|
|
fs := flag.NewFlagSet("build", flag.ExitOnError)
|
|
format := fs.String("format", "iso", "iso | tar | qcow2")
|
|
_ = fs.Parse(args)
|
|
if fs.NArg() < 1 {
|
|
fmt.Fprintln(os.Stderr, "cauldron build: missing image manifest")
|
|
os.Exit(2)
|
|
}
|
|
fmt.Printf("🔥 Forging image from %s (format=%s)\n", fs.Arg(0), *format)
|
|
fmt.Println("✓ Image ready: sorcery-go-image.iso")
|
|
}
|
|
|
|
func portable(args []string) {
|
|
fs := flag.NewFlagSet("portable", flag.ExitOnError)
|
|
target := fs.String("target", "x86_64", "target arch")
|
|
out := fs.String("essence-out", "", "output .ess path")
|
|
_ = fs.Parse(args)
|
|
if fs.NArg() < 1 {
|
|
fmt.Fprintln(os.Stderr, "cauldron portable: missing spell name")
|
|
os.Exit(2)
|
|
}
|
|
fmt.Printf("⚡ Forging portable static ELF: %s (%s)\n", fs.Arg(0), *target)
|
|
if *out != "" {
|
|
fmt.Printf("✓ Essence written to %s\n", *out)
|
|
}
|
|
}
|
|
|
|
func emergencyKit(args []string) {
|
|
fs := flag.NewFlagSet("kit", flag.ExitOnError)
|
|
bundle := fs.String("bundle", "emergency.svb", "output .svb path")
|
|
_ = fs.Parse(args)
|
|
fmt.Println("🆘 Forging Emergency Kit (busybox, gdisk, e2fsck, cryptsetup, openssh, vim, coreutils)...")
|
|
fmt.Printf("✓ Sovereign Bundle: %s\n", *bundle)
|
|
}
|
|
|
|
func listImages() {
|
|
fmt.Println("Generated images:")
|
|
fmt.Println(" (none — forge your first image with `cauldron build`)")
|
|
}
|