Sha256: fab562c77e501fc91ece71aa60e6164c966cd7bf7ce413d258fe2cb6f35eaa3a
Contents?: true
Size: 922 Bytes
Versions: 5
Compression:
Stored size: 922 Bytes
Contents
module UltraCommandLine module Commands module HelpFormatter DEFAULT_SEPARATOR_WIDTH = 80 DEFAULT_SEPARATOR_FILLER = '-'.freeze DEFAULT_TITLE = 'Options'.freeze attr_writer :separator_width, :separator_filler def separator_width @separator_width ||= DEFAULT_SEPARATOR_WIDTH end def title name.nil? || name.empty? ? DEFAULT_TITLE : name end def separator_filler @separator_filler ||= DEFAULT_SEPARATOR_FILLER end def help output = [] output << banner unless options.empty? output << build_separator(title) output.concat options.sort{|a,b| a.name <=> b.name }.map(&:help_line) end output end private def build_separator(title) "#{separator_filler * 2} #{title} ".ljust separator_width, separator_filler end end end end
Version data entries
5 entries across 5 versions & 1 rubygems