Cross-Platform Crucible (#2)
test-image / build-image (push) Successful in 44s
test / test (push) Successful in 1m20s
build-binaries / build-binaries (push) Successful in 2m0s
build-image / publish (push) Successful in 12s

Crucible groundwork for cross-platform compatibility.

Reviewed-on: #2
Reviewed-by: xtul <mpiasecki720@protonmail.com>
Co-authored-by: vickydotbat <vickydotbat@tutamail.com>
Co-committed-by: vickydotbat <vickydotbat@tutamail.com>
This commit was merged in pull request #2.
This commit is contained in:
2026-06-16 13:52:19 +00:00
committed by archvillainette
parent e9d82816b7
commit 93433e3f53
11 changed files with 465 additions and 43 deletions
+47 -2
View File
@@ -17,6 +17,7 @@ import (
"git.westgate.pw/ShadowsOverWestgate/sow-tools/internal/app"
"git.westgate.pw/ShadowsOverWestgate/sow-tools/internal/buildinfo"
"git.westgate.pw/ShadowsOverWestgate/sow-tools/internal/menu"
)
// Exit codes follow the sysexits(3) convention so CI can distinguish
@@ -103,8 +104,52 @@ func find(name string) (Builder, bool) {
return Builder{}, false
}
// Main is the `crucible` dispatcher entrypoint.
func Main(args []string) int { return run(args, os.Stdout, os.Stderr) }
// Main is the `crucible` dispatcher entrypoint. With no arguments on an
// interactive terminal it launches the menu; otherwise (pipes, CI) it prints
// usage, preserving scriptable behavior.
func Main(args []string) int {
if len(args) == 0 && interactive(os.Stdout) {
return runMenu(os.Stdout, os.Stderr, os.Stdin)
}
return run(args, os.Stdout, os.Stderr)
}
func interactive(f *os.File) bool {
fi, err := f.Stat()
if err != nil {
return false
}
return fi.Mode()&os.ModeCharDevice != 0
}
func menuItems() []menu.Item {
var items []menu.Item
for _, b := range Registry {
if !b.Wired {
continue
}
for _, sub := range b.subcommands() {
items = append(items, menu.Item{
Label: b.Name + " " + sub,
Desc: b.Summary,
Args: []string{b.Name, sub},
})
}
}
return items
}
func runMenu(out, errw io.Writer, in io.Reader) int {
chosen, err := menu.Select(out, in, menuItems())
if err != nil {
fmt.Fprintln(errw, "crucible:", err)
return exitUsage
}
if chosen == nil {
return exitOK
}
return run(chosen, out, errw)
}
// RunBuilder is the standalone `crucible-<name>` entrypoint.
func RunBuilder(name string, args []string) int {