class Cri::HelpRenderer

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

Constants

DESC_INDENT

The indentation of descriptions

LINE_WIDTH

The line width of the help output

OPT_DESC_SPACING

The spacing between an option name and option description

Public Instance Methods

render() click to toggle source

@return [String] The help text for this command

# File lib/cri/help_renderer.rb, line 27
def render
  text = ''

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

  text
end

Public Class Methods

new(cmd, params = {}) click to toggle source

Creates a new help renderer for the given command.

@param [Cri::Command] cmd The command to generate the help for

@option params [Boolean] :verbose true if the help output should be

verbose, false otherwise.
# File lib/cri/help_renderer.rb, line 20
def initialize(cmd, params = {})
  @cmd        = cmd
  @is_verbose = params.fetch(:verbose, false)
  @io         = params.fetch(:io, $stdout)
end