()
| 94 | var rawInvocationArgs []string |
| 95 | |
| 96 | func Execute() int { |
| 97 | rawInvocationArgs = os.Args[1:] |
| 98 | inv, err := BootstrapInvocationContext(os.Args[1:]) |
| 99 | if err != nil { |
| 100 | fmt.Fprintln(os.Stderr, "Error:", err) |
| 101 | return 1 |
| 102 | } |
| 103 | configureFlagCompletions(os.Args) |
| 104 | |
| 105 | ctx := context.Background() |
| 106 | f, rootCmd, reg := buildInternal( |
| 107 | ctx, inv, |
| 108 | WithIO(os.Stdin, os.Stdout, os.Stderr), |
| 109 | HideProfile(isSingleAppMode()), |
| 110 | ) |
| 111 | |
| 112 | // --- Notices (non-blocking) --- |
| 113 | if !isCompletionCommand(os.Args) { |
| 114 | setupNotices() |
| 115 | } |
| 116 | |
| 117 | runErr := rootCmd.Execute() |
| 118 | |
| 119 | // Fire Shutdown lifecycle hooks regardless of run outcome. |
| 120 | // emitShutdown imposes a 2s total deadline and never propagates handler |
| 121 | // errors (Emit's documented Shutdown contract), so it cannot block exit |
| 122 | // or alter the user-visible exit code. |
| 123 | if reg != nil && !isCompletionCommand(os.Args) { |
| 124 | _ = hook.Emit(ctx, reg, platform.Shutdown, runErr) |
| 125 | } |
| 126 | |
| 127 | if runErr != nil { |
| 128 | return handleRootError(f, runErr) |
| 129 | } |
| 130 | return 0 |
| 131 | } |
| 132 | |
| 133 | // setupNotices wires both the binary update notice and the skills |
| 134 | // staleness notice into output.PendingNotice as a composed function. |
no test coverage detected