Class: Cri::HelpRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/cri/help_renderer.rb

Overview

The HelpRenderer class is responsible for generating a string containing the help for a given command, intended to be printed on the command line.

Instance Method Summary (collapse)

Constructor Details

- (HelpRenderer) initialize(cmd, params = {})

Creates a new help renderer for the given command.

Parameters:

  • cmd (Cri::Command)

    The command to generate the help for

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :verbose (Boolean)

    true if the help output should be verbose, false otherwise.



15
16
17
18
# File 'lib/cri/help_renderer.rb', line 15

def initialize(cmd, params={})
  @cmd        = cmd
  @is_verbose = params.fetch(:verbose, false)
end

Instance Method Details

- (String) render

Returns The help text for this command

Returns:

  • (String)

    The help text for this command



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

def render
  text = ''

  append_summary(text)
  append_usage(text)
  append_description(text)
  append_subcommands(text)
  append_options(text)

  text
end