Class: EacCli::RunnerWith::Help::Builder
- Defined in:
- lib/eac_cli/runner_with/help/builder.rb,
lib/eac_cli/runner_with/help/builder/alternative.rb
Defined Under Namespace
Classes: Alternative
Constant Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
- #option_definition(option) ⇒ Object
- #options_section ⇒ Object
- #section(header, include_header = true) ⇒ Object
- #to_s ⇒ Object
- #usage_section ⇒ Object
Class Method Details
.option_long(option) ⇒ Object
17 18 19 20 21 |
# File 'lib/eac_cli/runner_with/help/builder.rb', line 17 def option_long(option) b = option.long b += '=<value>' if option.argument? b end |
.option_short(option) ⇒ Object
23 24 25 26 27 |
# File 'lib/eac_cli/runner_with/help/builder.rb', line 23 def option_short(option) b = option.short b += '=<value>' if option.argument? b end |
Instance Method Details
#option_definition(option) ⇒ Object
38 39 40 41 42 |
# File 'lib/eac_cli/runner_with/help/builder.rb', line 38 def option_definition(option) self.class.option_usage_full(option) + option.description.if_present('') do |v| OPTION_DESC_SEP + v end end |
#options_section ⇒ Object
54 55 56 57 58 |
# File 'lib/eac_cli/runner_with/help/builder.rb', line 54 def "Options:\n" + definition.alternatives.flat_map(&:options) .map { |option| IDENT + option_definition(option) + "\n" }.join end |
#section(header, include_header = true) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/eac_cli/runner_with/help/builder.rb', line 44 def section(header, include_header = true) b = include_header ? "#{header.humanize}:\n" : '' b += send("self_#{header}") + "\n" definition.alternatives.each do |alternative| b += IDENT + ::EacCli::RunnerWith::Help::Builder::Alternative.new(alternative).to_s + "\n" end b end |
#to_s ⇒ Object
67 68 69 |
# File 'lib/eac_cli/runner_with/help/builder.rb', line 67 def to_s "#{definition.description}\n\n#{usage_section}\n#{}\n" end |
#usage_section ⇒ Object
60 61 62 63 64 65 |
# File 'lib/eac_cli/runner_with/help/builder.rb', line 60 def usage_section "Usage:\n" + definition.alternatives.map do |alternative| IDENT + ::EacCli::RunnerWith::Help::Builder::Alternative.new(alternative).to_s + "\n" end.join end |