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
31 32 33 34 35 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 31 def option_argument(option) b = option.long b += '=<value>' if option.argument? b end |
#options ⇒ Object
25 26 27 28 29 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 25 def alternative..select(&:show_on_usage?).map do |option| ::EacCli::RunnerWith::Help::Builder.option_long(option) end end |
#positional(positional) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 41 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
37 38 39 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 37 def positionals alternative.positional.map { |p| positional(p) }.reject(&:blank?) end |
#program_name ⇒ Object
54 55 56 57 58 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 54 def program_name r = builder.runner.program_name r = [r] unless r.is_a?(::Enumerable) r end |
#result ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/eac_cli/runner_with/help/builder/alternative.rb', line 16 def result ( program_name + alternative..if_present([]) { |_v| ['[options]'] } + + positionals ).join(builder.word_separator) end |