Function
ExecuteContext
(ctx context.Context, args []string, stdout io.Writer, stderr io.Writer)
Source from the content-addressed store, hash-verified
| 172 | } |
| 173 | |
| 174 | func ExecuteContext(ctx context.Context, args []string, stdout io.Writer, stderr io.Writer) int { |
| 175 | cmd := NewRootCommand() |
| 176 | cmd.SetArgs(args) |
| 177 | cmd.SetOut(stdout) |
| 178 | cmd.SetErr(stderr) |
| 179 | |
| 180 | if err := cmd.ExecuteContext(ctx); err != nil { |
| 181 | return writeExecutionError(stderr, args, err) |
| 182 | } |
| 183 | return 0 |
| 184 | } |
| 185 | |
| 186 | func writeExecutionError(stderr io.Writer, args []string, err error) int { |
| 187 | exitCode := cliExitCodeForError(err) |