Class: CLAide::Command::Banner

Inherits:
Object
  • Object
show all
Defined in:
lib/claide/command/banner.rb

Overview

Creates the formatted banner to present as help of the provided command class.

Defined Under Namespace

Modules: TextWrapper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ Banner



15
16
17
# File 'lib/claide/command/banner.rb', line 15

def initialize(command)
  @command = command
end

Instance Attribute Details

#commandClass



11
12
13
# File 'lib/claide/command/banner.rb', line 11

def command
  @command
end

Instance Method Details

#formatted_bannerString



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/claide/command/banner.rb', line 21

def formatted_banner
  sections = [
    ['Usage',    formatted_usage_description],
    ['Commands', formatted_subcommand_summaries],
    ['Options',  formatted_options_description],
  ]
  banner = sections.map do |(title, body)|
    [prettify_title("#{title}:"), body] unless body.empty?
  end.compact.join("\n\n")
  banner
end