Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate and reuse pager code for inline console docs #11961

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/rex/ui/text/dispatcher_shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ def cmd_help_help
#
def cmd_help(cmd=nil, *ignored)
if cmd
if docs_dir && File.exist?(File.join(docs_dir, cmd + '.md'))
print(File.read(File.join(docs_dir, cmd + '.md')))
print_line
end

help_found = false
cmd_found = false
shell.dispatcher_stack.each do |dispatcher|
Expand All @@ -175,18 +180,15 @@ def cmd_help(cmd=nil, *ignored)
end
end

if docs_dir && File.exist?(File.join(docs_dir, cmd + '.md'))
print_line
print(File.read(File.join(docs_dir, cmd + '.md')))
end
print_error("No help for #{cmd}, try -h") if cmd_found and not help_found
print_error("No such command") if not cmd_found
else
print(shell.help_to_s)
if docs_dir && File.exist?(File.join(docs_dir + '.md'))
print_line
print(File.read(File.join(docs_dir + '.md')))
print_line
end

print(shell.help_to_s)
end
end

Expand Down