class GLI::Commands::HelpModules::FullSynopsisFormatter

Public Instance Methods

synopses_for_command(command) click to toggle source
# File lib/gli/commands/help_modules/full_synopsis_formatter.rb, line 11
def synopses_for_command(command)
  synopses = []
  one_line_usage = basic_usage(command)
  one_line_usage << ArgNameFormatter.new.format(command.arguments_description,command.arguments_options,command.arguments).strip
  if command.commands.empty?
    synopses << one_line_usage
  else
    synopses = sorted_synopses(command)
    if command.has_action?
      synopses.unshift(one_line_usage)
    end
  end
  synopses
end

Protected Instance Methods

sub_options_doc(sub_options) click to toggle source
# File lib/gli/commands/help_modules/full_synopsis_formatter.rb, line 28
def sub_options_doc(sub_options)
  sub_options_doc = sub_options.map { |_,option| 
    doc = option.names_and_aliases.map { |name|
      CommandLineOption.name_as_string(name,false) + (option.kind_of?(Flag) ? " #{option.argument_name }" : '')
    }.join('|')
    option.required?? doc : "[#{doc}]"
  }.sort.join(' ').strip
end

Public Class Methods

new(app,flags_and_switches) click to toggle source
# File lib/gli/commands/help_modules/full_synopsis_formatter.rb, line 5
def initialize(app,flags_and_switches)
  @app = app
  @basic_invocation = @app.exe_name.to_s
  @flags_and_switches = flags_and_switches
end