Skip to content

Commit

Permalink
Merge pull request #19312 from knz/20171017-flex-help
Browse files Browse the repository at this point in the history
cli/sql: accept semicolons after client-local commands
  • Loading branch information
knz authored Oct 17, 2017
2 parents fc8a0ce + 3c7fd43 commit c86f16f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pkg/cli/interactive_tests/test_local_cmds.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ eexpect "with no argument"
eexpect root@
end_test

start_test "Check that commands are also recognized with a final semicolon."
send "\\set;\r"
eexpect "display_format"
eexpect root@
send "\\h select;\r"
eexpect SELECT
eexpect Description
eexpect root@
end_test

# Finally terminate with Ctrl+C.
interrupt
eexpect eof
Expand Down
6 changes: 5 additions & 1 deletion pkg/cli/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,11 @@ func (c *cliState) doHandleCliCmd(loopState, nextState cliStateEnum) cliStateEnu
// to handle it as a statement, so save the history.
c.addHistory(c.lastInputLine)

cmd := strings.Fields(c.lastInputLine)
// As a convenience to the user, we strip the final semicolon, if
// any, in all cases.
line := strings.TrimRight(c.lastInputLine, "; ")

cmd := strings.Fields(line)
switch cmd[0] {
case `\q`, `\quit`, `\exit`:
return cliStop
Expand Down

0 comments on commit c86f16f

Please sign in to comment.