File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -77,12 +77,31 @@ def help_to_s(opts = {})
77
77
super + format_session_compatible_modules
78
78
end
79
79
80
+ #
81
+ # Notification to display when initially interacting with the client via the query_interactive command
82
+ #
83
+ # @return [String]
84
+ def interact_with_client_notification
85
+ print_status ( "Starting interactive SQL shell for #{ sql_prompt } " )
86
+ print_status ( 'SQL commands ending with ; will be executed on the remote server. Use the %grnexit%clr command to exit.' )
87
+ print_line
88
+ end
89
+
90
+ #
91
+ # Create prompt via client and session data
92
+ #
93
+ # @return [String]
94
+ def sql_prompt
95
+ "#{ session . type } @ #{ client . peerinfo } (#{ current_database } )"
96
+ end
97
+
80
98
#
81
99
# Interacts with the supplied client.
82
100
#
83
101
def interact_with_client ( client_dispatcher : nil )
84
102
return unless client_dispatcher
85
103
104
+ interact_with_client_notification
86
105
client . extend ( InteractiveSqlClient ) unless client . is_a? ( InteractiveSqlClient )
87
106
client . on_command_proc = self . on_command_proc if self . on_command_proc && client . respond_to? ( :on_command_proc )
88
107
client . on_print_proc = self . on_print_proc if self . on_print_proc && client . respond_to? ( :on_print_proc )
@@ -96,8 +115,7 @@ def interact_with_client(client_dispatcher: nil)
96
115
# @param [Object] val
97
116
# @return [String]
98
117
def format_prompt ( val )
99
- prompt = "%und#{ session . type } @ #{ client . peerinfo } (#{ current_database } )%clr > "
100
- substitute_colors ( prompt , true )
118
+ substitute_colors ( "%und#{ sql_prompt } %clr > " , true )
101
119
end
102
120
103
121
#
You can’t perform that action at this time.
0 commit comments