Skip to content

Commit 326b7ba

Browse files
add func to pass ctx to Main
1 parent 4250b42 commit 326b7ba

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

builder.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ func Name(obj any) string {
7373
return commandName
7474
}
7575

76-
func Main(cmd *cobra.Command) {
77-
ctx := SetupSignalContext()
76+
func MainCtx(ctx context.Context, cmd *cobra.Command) {
7877
if err := cmd.ExecuteContext(ctx); err != nil {
7978
if strings.EqualFold("interrupt", err.Error()) || errors.Is(err, context.Canceled) {
8079
os.Exit(1)
@@ -83,6 +82,10 @@ func Main(cmd *cobra.Command) {
8382
}
8483
}
8584

85+
func Main(cmd *cobra.Command) {
86+
MainCtx(SetupSignalContext(), cmd)
87+
}
88+
8689
// Command populates a cobra.Command object by extracting args from struct tags of the
8790
// Runnable obj passed. The Run method is assigned to the RunE of the command.
8891
// children should be either Runnable or *cobra.Command

0 commit comments

Comments
 (0)