diff --git a/lib/rex/post/sql/ui/console/command_dispatcher/client.rb b/lib/rex/post/sql/ui/console/command_dispatcher/client.rb index aca92d3b670e..66304b2dc4d4 100644 --- a/lib/rex/post/sql/ui/console/command_dispatcher/client.rb +++ b/lib/rex/post/sql/ui/console/command_dispatcher/client.rb @@ -134,22 +134,33 @@ def run_query(query) end def cmd_query(*args) - @@query_opts.parse(args) do |opt, idx, val| + show_help = false + call_interactive = false + + @@query_opts.parse(args) do |opt, _idx, val| case opt + when nil + show_help = true if val == 'help' + break when '-h', '--help' - cmd_query_help - return + show_help = true + break when '-i', '--interact' - cmd_query_interactive - return + call_interactive = true + break end end - if args.empty? + if args.empty? || show_help cmd_query_help return end + if call_interactive + cmd_query_interactive + return + end + result = run_query(args.join(' ')) case result[:status] when :success diff --git a/lib/rex/ui/text/dispatcher_shell.rb b/lib/rex/ui/text/dispatcher_shell.rb index f7dc25cb3d91..2131cc363292 100644 --- a/lib/rex/ui/text/dispatcher_shell.rb +++ b/lib/rex/ui/text/dispatcher_shell.rb @@ -663,7 +663,7 @@ def help_to_s(opts = {}) str << dispatcher.help_to_s(opts.merge({ command_width: [max_command_length, 12].max })) } - return str + return str << "For more info on a specific command, use %grn -h%clr or %grnhelp %clr.\n\n" end