Class: Convoy::Formatter::DefaultHelpFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/convoy/formatter/default_help_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(setup, context) ⇒ DefaultHelpFormatter

Returns a new instance of DefaultHelpFormatter.



6
7
8
9
# File 'lib/convoy/formatter/default_help_formatter.rb', line 6

def initialize(setup, context)
    @setup   = setup
    @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



4
5
6
# File 'lib/convoy/formatter/default_help_formatter.rb', line 4

def context
  @context
end

#setupObject (readonly)

Returns the value of attribute setup.



4
5
6
# File 'lib/convoy/formatter/default_help_formatter.rb', line 4

def setup
  @setup
end

Instance Method Details



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/convoy/formatter/default_help_formatter.rb', line 11

def print(parser)
    options         = Options.new(parser, setup, context)
    commands        = Commands.new(setup, context)
    current_command = Commands.command_for(setup, context)
    # Uncomment the following line if you want the screen
    # to be cleared before the --help messages show.
    #
    # system('clear')
    puts
    StreamOutputFormatter.new($stdout, :max_output_width => Terminal.width) do |f|
        if setup.summary_for != '' && !setup.summary_for.nil?
            f.puts setup.summary_for, :newlines => 2
        end
        # if (setup.description_for != '' && !setup.description_for.nil?) && current_command.summary == setup.summary_for
        #     f.indent(4) do |f_inner|
        #         f_inner.puts setup.description_for, :newlines => 2
        #     end
        # end
        name_help(current_command, f)
        version_help(current_command, f)
        usage_help(current_command, f)
        commands_help(commands, f)
        options_help(options, f)
    end
end