(input string, displayTable bool)
| 230 | } |
| 231 | |
| 232 | func (c *Cli) RunBatch(input string, displayTable bool) int { |
| 233 | cmds, err := buildCommands(input) |
| 234 | if err != nil { |
| 235 | c.PrintBatchError(err) |
| 236 | return exitCodeError |
| 237 | } |
| 238 | |
| 239 | ctx, cancel := context.WithCancel(context.Background()) |
| 240 | go handleInterrupt(cancel) |
| 241 | |
| 242 | for _, cmd := range cmds { |
| 243 | result, err := cmd.Stmt.Execute(ctx, c.Session) |
| 244 | if err != nil { |
| 245 | c.PrintBatchError(err) |
| 246 | return exitCodeError |
| 247 | } |
| 248 | |
| 249 | if displayTable { |
| 250 | c.PrintResult(result, DisplayModeTable, false) |
| 251 | } else if cmd.Vertical { |
| 252 | c.PrintResult(result, DisplayModeVertical, false) |
| 253 | } else { |
| 254 | c.PrintResult(result, DisplayModeTab, false) |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | return exitCodeSuccess |
| 259 | } |
| 260 | |
| 261 | func (c *Cli) Exit() int { |
| 262 | c.Session.Close() |
no test coverage detected