aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/fpkg/proc.go
blob: 677ddb75b7cc0b15c46deaacd3d2f0f7cacc0232 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main

import (
	"context"
	"os"

	"git.gensokyo.uk/security/fortify/fst"
	"git.gensokyo.uk/security/fortify/internal/app"
	"git.gensokyo.uk/security/fortify/internal/fmsg"
)

func mustRunApp(ctx context.Context, config *fst.Config, beforeFail func()) {
	rs := new(fst.RunState)
	a := app.MustNew(ctx, std)

	var code int
	if sa, err := a.Seal(config); err != nil {
		fmsg.PrintBaseError(err, "cannot seal app:")
		code = 1
	} else {
		code = app.PrintRunStateErr(rs, sa.Run(rs))
	}

	if code != 0 {
		beforeFail()
		os.Exit(code)
	}
}