Execute dispatches a subcommand with the given args.
(ctx context.Context, cmd string, args []string)
| 190 | |
| 191 | // Execute dispatches a subcommand with the given args. |
| 192 | func (e *Engine) Execute(ctx context.Context, cmd string, args []string) error { |
| 193 | switch cmd { |
| 194 | case "read": |
| 195 | return e.handleRead(args) |
| 196 | case "write": |
| 197 | return e.handleWrite(args) |
| 198 | case "patch": |
| 199 | return e.handlePatch(args) |
| 200 | case "multipatch": |
| 201 | return e.handleMultipatch(args) |
| 202 | case "tree": |
| 203 | return e.handleTree(args) |
| 204 | case "search": |
| 205 | return e.handleSearch(ctx, args) |
| 206 | case "exec": |
| 207 | return e.handleExec(ctx, args) |
| 208 | case "rollback": |
| 209 | return e.handleRollback(args) |
| 210 | case "clean": |
| 211 | return e.handleClean(args) |
| 212 | case "git-status": |
| 213 | return e.handleGitStatus(ctx, args) |
| 214 | case "git-diff": |
| 215 | return e.handleGitDiff(ctx, args) |
| 216 | case "git-log": |
| 217 | return e.handleGitLog(ctx, args) |
| 218 | case "git-changed": |
| 219 | return e.handleGitChanged(ctx, args) |
| 220 | case "git-branch": |
| 221 | return e.handleGitBranch(ctx, args) |
| 222 | case "test": |
| 223 | return e.handleTest(ctx, args) |
| 224 | default: |
| 225 | return fmt.Errorf("comando desconhecido: %s", cmd) |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | func (e *Engine) printf(format string, a ...interface{}) { |
| 230 | _, _ = fmt.Fprintf(e.Out, format, a...) |