forked from gittuf/gittuf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
31 lines (25 loc) · 858 Bytes
/
main.go
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
29
30
31
// SPDX-License-Identifier: Apache-2.0
package main
import (
"fmt"
"os"
"runtime/debug"
"github.com/gittuf/gittuf/internal/cmd/root"
)
func main() {
defer func() {
if r := recover(); r != nil {
fmt.Fprintf(os.Stderr, "unexpected error: %s\n\n", fmt.Sprint(r))
debug.PrintStack()
fmt.Fprintln(os.Stderr, "\nPlease consider filing a bug on https:/github.com/gittuf/gittuf/issues with the stack trace and steps to reproduce this state. Thanks!")
os.Exit(1) // this is the last possible deferred function to run
}
}()
rootCmd := root.New()
if err := rootCmd.Execute(); err != nil {
// We can ignore the linter here (deferred functions are not executed
// when os.Exit is invoked) because if we do have an error, we don't
// have a panic, which is what the deferred function is looking for.
os.Exit(1) //nolint:gocritic
}
}