Run executes the CLI and returns the process exit code. errEndpointsHandled from PersistentPreRunE is translated to a successful exit so the global --endpoints short-circuit behaves identically to Python's typer.Exit().
(args []string)
| 48 | // from PersistentPreRunE is translated to a successful exit so the global |
| 49 | // --endpoints short-circuit behaves identically to Python's typer.Exit(). |
| 50 | func (a *App) Run(args []string) int { |
| 51 | cmd := a.rootCommand() |
| 52 | cmd.SetArgs(args) |
| 53 | cmd.SetOut(a.stdout) |
| 54 | cmd.SetErr(a.stderr) |
| 55 | cmd.SetIn(a.stdin) |
| 56 | cmd.SilenceUsage = true |
| 57 | cmd.SilenceErrors = true |
| 58 | |
| 59 | if err := cmd.Execute(); err != nil { |
| 60 | if errors.Is(err, errEndpointsHandled) { |
| 61 | return 0 |
| 62 | } |
| 63 | fmt.Fprintln(a.stderr, err.Error()) |
| 64 | return 1 |
| 65 | } |
| 66 | return 0 |
| 67 | } |
| 68 | |
| 69 | func (a *App) rootCommand() *cobra.Command { |
| 70 | state := &globalState{} |
nothing calls this directly
no test coverage detected