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
- 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.
20 21 22 23 24 |
# 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 |
Instance Method Details
#render ⇒ String
Returns The help text for this command
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cri/help_renderer.rb', line 27 def render text = '' append_summary(text) append_usage(text) append_description(text) append_subcommands(text) (text) text end |