Skip to content

Commit

Permalink
make session query/shares help menu more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
zgoldman-r7 committed Mar 19, 2024
1 parent 923f4c9 commit 2748a91
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/rex/post/smb/ui/console/command_dispatcher/shares.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def initialize(console)
#
def commands
cmds = {
'shares' => 'View the available shares and interact with one',
'shares' => 'View the available shares and interact with one. Use the -h flag for more info',
'ls' => 'List all files in the current directory',
'dir' => 'List all files in the current directory (alias for ls)',
'pwd' => 'Print the current remote working directory',
Expand Down
26 changes: 19 additions & 7 deletions lib/rex/post/sql/ui/console/command_dispatcher/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def initialize(console)
#
def commands
cmds = {
'query' => 'Run a single SQL query',
'query' => 'Run a single SQL query. Use the -h flag for more info',
'query_interactive' => 'Enter an interactive prompt for running multiple SQL queries',
}

Expand Down Expand Up @@ -134,22 +134,34 @@ 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 statements make whatever flag comes first take precedence; removing would make help take precedence. Is this the pattern we want? Should we change it? Or listen to both flags?
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
Expand Down

0 comments on commit 2748a91

Please sign in to comment.