Class: EacCli::RunnerWith::Help::Builder::Alternative
- Defined in:
- lib/eac_cli/runner_with/help/builder/alternative.rb
Constant Summary collapse
- PROGRAM_MACRO =
'__PROGRAM__'
- SUBCOMMANDS_MACRO =
'__SUBCOMMANDS__'
Instance Method Summary collapse
- #option_argument(option) ⇒ Object
- #options ⇒ Object
- #positional(positional) ⇒ Object
- #positionals ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#option_argument(option) ⇒ Object
30 31 32 33 34 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 30 def option_argument(option) b = option.long b += '=<value>' if option.argument? b end |
#options ⇒ Object
24 25 26 27 28 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 24 def alternative..select(&:show_on_usage?).map do |option| ::EacCli::RunnerWith::Help::Builder.option_long(option) end end |
#positional(positional) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 40 def positional(positional) return unless positional.visible? if positional.subcommand? SUBCOMMANDS_MACRO else r = "<#{positional.name}>" r += '...' if positional.repeat? r = "[#{r}]" if positional.optional? r end end |
#positionals ⇒ Object
36 37 38 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 36 def positionals alternative.positional.map { |p| positional(p) }.reject(&:blank?) end |
#to_s ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 15 def to_s ( [PROGRAM_MACRO] + alternative..if_present([]) { |_v| ['[options]'] } + + positionals ).join(::EacCli::RunnerWith::Help::Builder::SEP) end |