@@ -22,6 +22,11 @@ def _interact
22
22
while self . interacting
23
23
sql_input = _multiline_with_fallback
24
24
self . interacting = ( sql_input [ :status ] != :exit )
25
+
26
+ if sql_input [ :status ] == :help
27
+ client_dispatcher . query_interactive_help
28
+ end
29
+
25
30
# We need to check that the user is still interacting, i.e. if ctrl+z is triggered when requesting user input
26
31
break unless ( self . interacting && sql_input [ :result ] )
27
32
@@ -77,8 +82,10 @@ def _multiline
77
82
end
78
83
79
84
stop_words = %w[ stop s exit e end quit q ] . freeze
85
+ help_words = %w[ help h ] . freeze
80
86
81
87
finished = false
88
+ help = false
82
89
begin
83
90
result = nil
84
91
prompt_proc_before = ::Reline . prompt_proc
@@ -100,10 +107,14 @@ def _multiline
100
107
next true
101
108
end
102
109
103
- # In the case only a stop word was input, exit out of the REPL shell
104
- finished = ( multiline_input . split . count == 1 && stop_words . include? ( multiline_input . split . last ) )
110
+ if multiline_input . split . count == 1
111
+ # In the case only a stop word was input, exit out of the REPL shell
112
+ finished = stop_words . include? ( multiline_input . split . last )
113
+ # In the case when only a help word was input call the help command
114
+ help = help_words . include? ( multiline_input . split . last )
115
+ end
105
116
106
- finished || multiline_input . split . last &.end_with? ( ';' )
117
+ finished || help || multiline_input . split . last &.end_with? ( ';' )
107
118
end
108
119
rescue ::StandardError => e
109
120
elog ( 'Failed to get multi-line SQL query from user' , e )
@@ -115,6 +126,10 @@ def _multiline
115
126
return result
116
127
end
117
128
129
+ if help
130
+ return { status : :help , result : nil }
131
+ end
132
+
118
133
if finished
119
134
self . interacting = false
120
135
print_status 'Exiting Interactive mode.'
0 commit comments