lib/claide/command/banner/prettifier.rb in claide-0.6.1 vs lib/claide/command/banner/prettifier.rb in claide-0.7.0
- old
+ new
@@ -16,26 +16,28 @@
#
def self.prettify_signature(command, subcommand, argument)
components = [
[command, :green],
[subcommand, :green],
- [argument, :magenta]
+ [argument, :magenta],
]
components.reduce('') do |memo, (string, ansi_key)|
- memo << ' ' << string.ansi.apply(ansi_key) unless string.empty?
- memo
+ next memo if !string || string.empty?
+ memo << ' ' << string.ansi.apply(ansi_key)
end.lstrip
end
# @return [String] A decorated command description.
#
def self.prettify_message(command, message)
message = message.dup
- [[command.arguments, :magenta],
- [command.options, :blue]].each do |(list, ansi_key)|
- list.map(&:first).each do |name|
- message.gsub!(/`#{name}`/, "`#{name}`".ansi.apply(ansi_key))
+ command.arguments.each do |arg|
+ arg.names.each do |name|
+ message.gsub!("`#{name.gsub(/\.{3}$/, '')}`", '\0'.ansi.magenta)
end
+ end
+ command.options.each do |(name, _description)|
+ message.gsub!("`#{name}`", '\0'.ansi.blue)
end
message
end
# @return [String] A decorated textual representation of the subcommand