-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathmain.go
More file actions
51 lines (42 loc) · 1.03 KB
/
main.go
File metadata and controls
51 lines (42 loc) · 1.03 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"os"
"strings"
"github.com/go-errors/errors"
"github.com/smithy-security/smithy/smithyctl/command/component"
"github.com/smithy-security/smithy/smithyctl/command/version"
"github.com/smithy-security/smithy/smithyctl/command/workflow"
"github.com/smithy-security/smithy/smithyctl/internal/command"
)
func main() {
err := command.
NewRootCommand(
version.NewCommand(),
component.NewCommand(),
workflow.NewCommand(),
).
Execute()
if err != nil {
errToUnwrap := err
errPrintQueue := []string{}
for errToUnwrap != nil {
if _, canPrintStackTrace := errToUnwrap.(*errors.Error); canPrintStackTrace {
errPrintQueue = append(errPrintQueue, string(errToUnwrap.(*errors.Error).Stack()))
}
errToUnwrap = errors.Unwrap(errToUnwrap)
}
if len(errPrintQueue) > 0 {
_, printErr := fmt.Fprint(
os.Stderr,
"\nError stack trace is:\n\n",
strings.Join(errPrintQueue, "\ncaused by:\n"),
"\n",
)
if printErr != nil {
panic(printErr.Error())
}
}
os.Exit(1)
}
}