Class: GLI::Commands::HelpModules::TerminalSynopsisFormatter

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

Instance Method Summary collapse

Constructor Details

#initialize(app, flags_and_switches) ⇒ TerminalSynopsisFormatter

Returns a new instance of TerminalSynopsisFormatter.



5
6
7
8
9
# File 'lib/gli/commands/help_modules/terminal_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



10
11
12
13
14
15
16
17
18
# File 'lib/gli/commands/help_modules/terminal_synopsis_formatter.rb', line 10

def synopses_for_command(command)
  synopses = FullSynopsisFormatter.new(@app,@flags_and_switches).synopses_for_command(command)
  if synopses.any? { |synopsis| synopsis.length > Terminal.instance.size[0] }
    CompactSynopsisFormatter.new(@app,@flags_and_switches).synopses_for_command(command)

  else
    synopses
  end
end