help: improve command --help output.
This commit is contained in:
parent
1bdcd2001c
commit
4ace1af297
@ -76,10 +76,13 @@ module Homebrew
|
||||
|
||||
def command_help(path)
|
||||
# Let OptionParser generate help text for commands which have a parser defined
|
||||
cmd = path.basename(path.extname)
|
||||
cmd_args_method_name = "#{cmd.to_s.tr("-", "_")}_args".to_sym
|
||||
begin
|
||||
cmd = path.basename(path.extname)
|
||||
return Homebrew.send("#{cmd.to_s.tr("-", "_")}_args".to_sym).generate_help_text
|
||||
rescue NoMethodError
|
||||
return Homebrew.send(cmd_args_method_name)
|
||||
.generate_help_text
|
||||
rescue NoMethodError => e
|
||||
raise if e.name != cmd_args_method_name
|
||||
nil
|
||||
end
|
||||
|
||||
@ -89,7 +92,8 @@ module Homebrew
|
||||
HOMEBREW_HELP
|
||||
else
|
||||
help_lines.map do |line|
|
||||
line.sub(/^ \* /, "#{Tty.bold}brew#{Tty.reset} ")
|
||||
line.gsub(/^ /, "")
|
||||
.sub(/^\* /, "#{Tty.bold}Usage: brew#{Tty.reset} ")
|
||||
.gsub(/`(.*?)`/, "#{Tty.bold}\\1#{Tty.reset}")
|
||||
.gsub(%r{<([^\s]+?://[^\s]+?)>}) { |url| Formatter.url(url) }
|
||||
.gsub(/<(.*?)>/, "#{Tty.underline}\\1#{Tty.reset}")
|
||||
|
@ -20,7 +20,7 @@ describe "brew", :integration_test do
|
||||
|
||||
it "prints help for a documented shell command" do
|
||||
expect { brew "help", "update" }
|
||||
.to output(/^brew update/).to_stdout
|
||||
.to output(/^Usage: brew update/).to_stdout
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user