Class: GLI::Commands::HelpModules::FullSynopsisFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/gli/commands/help_modules/full_synopsis_formatter.rb

Direct Known Subclasses

CompactSynopsisFormatter

Instance Method Summary collapse

Constructor Details

#initialize(app, flags_and_switches) ⇒ FullSynopsisFormatter

Returns a new instance of FullSynopsisFormatter.



5
6
7
8
9
# 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

Instance Method Details

#synopses_for_command(command) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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