Class: Cri::HelpRenderer
- Inherits:
-
Object
- Object
- Cri::HelpRenderer
- 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.
Constant Summary collapse
- LINE_WIDTH =
The line width of the help output
78
- DESC_INDENT =
The indentation of descriptions
4
- OPT_DESC_SPACING =
The spacing between an option name and option description
6
Instance Method Summary collapse
-
#initialize(cmd, **params) ⇒ HelpRenderer
constructor
Creates a new help renderer for the given command.
-
#render ⇒ String
The help text for this command.
Constructor Details
#initialize(cmd, **params) ⇒ HelpRenderer
Creates a new help renderer for the given command.
22 23 24 25 26 |
# File 'lib/cri/help_renderer.rb', line 22 def initialize(cmd, **params) @cmd = cmd @is_verbose = params.fetch(:verbose, false) @io = params.fetch(:io, $stdout) end |
Instance Method Details
#render ⇒ String
Returns The help text for this command.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cri/help_renderer.rb', line 29 def render text = +'' append_summary(text) append_usage(text) append_description(text) append_subcommands(text) (text) text end |