diff --git a/cmd/app/main.go b/cmd/app/main.go index a10412e9..6171a27a 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -6,8 +6,10 @@ package main import ( "context" + "errors" "log" "os" + "os/exec" "os/signal" "path/filepath" "syscall" @@ -124,7 +126,35 @@ func main() { ) } + c.NewCommand( + "run", "Start the named application", + func(args []string) error { + if len(args) != 1 { + return errors.New("run requires 1 argument") + } + + var config *hst.Config + f, err := os.Open(base.Append("app", args[0]).String()) + if err != nil { + return err + } + config, err = parse(args[0], base, f) + if closeErr := f.Close(); err == nil { + err = closeErr + } + if err != nil { + return err + } + + return run(ctx, msg, config) + }, + ) + c.MustParse(os.Args[1:], func(err error) { + if e, ok := errors.AsType[*exec.ExitError](err); ok && e != nil { + os.Exit(e.ExitCode()) + } + if w, ok := err.(interface{ Unwrap() []error }); !ok { log.Fatal(err) } else {