Initial pipelines server, CLI, TUI, and Go installation

This commit is contained in:
2026-10-08 22:22:17 +01:00
commit 0f30a001c2
143 changed files with 17557 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"os/signal"
"path/filepath"
"pipelines/internal/cli"
"pipelines/internal/installation"
"syscall"
)
func main() {
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer cancel()
app := cli.App{Out: os.Stdout, Err: os.Stderr, In: os.Stdin}
args := os.Args[1:]
executable, err := os.Executable()
var config *installation.Config
if err == nil {
config, err = installation.Load(executable)
}
if err == nil && config != nil {
err = config.Environment()
if err == nil && len(args) > 0 && installation.Service(args[0]) {
err = syscall.Exec(config.Python, append([]string{config.Python, filepath.Join(config.Prefix, "lib/manage.py"), "--prefix", config.Prefix}, args...), os.Environ())
}
if len(args) == 0 {
args = []string{"tui"}
}
}
if err == nil && len(args) > 0 && installation.Service(args[0]) {
err = fmt.Errorf("%s requires a managed installation; run install.sh first", args[0])
}
if err == nil {
err = app.Run(ctx, args)
}
if err != nil {
jsonMode := false
for _, arg := range os.Args[1:] {
if arg == "--json" || arg == "-json" || arg == "--json=true" {
jsonMode = true
}
}
if jsonMode {
_ = json.NewEncoder(os.Stderr).Encode(map[string]string{"type": "error", "error": err.Error()})
} else {
fmt.Fprintln(os.Stderr, "pipelines:", err)
}
os.Exit(1)
}
}