Module: UltraCommandLine::Commands::HelpFormatter

Included in:
SubCommand
Defined in:
lib/ultra_command_line/commands/help_formatter.rb

Constant Summary collapse

DEFAULT_SEPARATOR_WIDTH =
80
DEFAULT_SEPARATOR_FILLER =
'-'.freeze
DEFAULT_TITLE =
'Options'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#separator_fillerObject



20
21
22
# File 'lib/ultra_command_line/commands/help_formatter.rb', line 20

def separator_filler
  @separator_filler ||= DEFAULT_SEPARATOR_FILLER
end

#separator_widthObject



12
13
14
# File 'lib/ultra_command_line/commands/help_formatter.rb', line 12

def separator_width
  @separator_width ||= DEFAULT_SEPARATOR_WIDTH
end

Instance Method Details

#helpObject



24
25
26
27
28
29
30
31
32
# File 'lib/ultra_command_line/commands/help_formatter.rb', line 24

def help
  output = []
  output << banner
  unless options.empty?
    output << build_separator(title)
    output.concat options.map(&:help_line)
  end
  output
end

#titleObject



16
17
18
# File 'lib/ultra_command_line/commands/help_formatter.rb', line 16

def title
  name.nil? || name.empty? ? DEFAULT_TITLE : name
end