From c1427fd295d63d141acadd03e41c5c73fb11212a Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Tue, 12 Apr 2016 14:36:15 +0800 Subject: help: support highlighted output Closes #68. Signed-off-by: Xu Cheng --- Library/Homebrew/cmd/help.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/help.rb b/Library/Homebrew/cmd/help.rb index 449d44d46..77b562745 100644 --- a/Library/Homebrew/cmd/help.rb +++ b/Library/Homebrew/cmd/help.rb @@ -56,7 +56,10 @@ module Homebrew cmd_path.read. split("\n"). grep(/^#:/). - map { |line| line.slice(2..-1).delete("`").sub(/^ \* /, "brew ") }. - join("\n") + map do |line| + line.slice(2..-1).sub(/^ \* /, "#{Tty.highlight}brew#{Tty.reset} "). + gsub(/`(.*?)`/, "#{Tty.highlight}\\1#{Tty.reset}"). + gsub(/<(.*?)>/, "#{Tty.em}\\1#{Tty.reset}") + end.join("\n") end end -- cgit v1.2.3