MCPcopy Create free account
hub / github.com/cloudspannerecosystem/spanner-cli / RunBatch

Method RunBatch

cli.go:232–259  ·  view source on GitHub ↗
(input string, displayTable bool)

Source from the content-addressed store, hash-verified

230}
231
232func (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
261func (c *Cli) Exit() int {
262 c.Session.Close()

Callers 1

mainFunction · 0.95

Calls 5

PrintBatchErrorMethod · 0.95
PrintResultMethod · 0.95
buildCommandsFunction · 0.85
handleInterruptFunction · 0.85
ExecuteMethod · 0.65

Tested by

no test coverage detected