Class: EacCli::RunnerWith::Help::Builder::Alternative
- Defined in:
- lib/eac_cli/runner_with/help/builder/alternative.rb
Constant Summary collapse
- SUBCOMMANDS_MACRO =
'__SUBCOMMANDS__'
Instance Method Summary collapse
- #option_argument(option) ⇒ Object
- #options ⇒ Object
- #positional(positional) ⇒ Object
- #positionals ⇒ Object
- #program_name ⇒ Object
- #result ⇒ Object
Instance Method Details
#option_argument(option) ⇒ Object
29 30 31 32 33 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 29 def option_argument(option) b = option.long b += '=<value>' if option.argument? b end |
#options ⇒ Object
23 24 25 26 27 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 23 def alternative..select(&:show_on_usage?).map do |option| ::EacCli::RunnerWith::Help::Builder.option_long(option) end end |
#positional(positional) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 39 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
35 36 37 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 35 def positionals alternative.positional.map { |p| positional(p) }.compact_blank end |
#program_name ⇒ Object
52 53 54 55 56 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 52 def program_name r = builder.runner.program_name r = [r] unless r.is_a?(::Enumerable) r end |
#result ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 14 def result ( program_name + alternative..if_present([]) { |_v| ['[options]'] } + + positionals ).join(builder.word_separator) end |