Class: GLI::Commands::HelpModules::CommandHelpFormat

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

Instance Method Summary collapse

Constructor Details

#initialize(command, app, sorter, synopsis_formatter_class, wrapper_class = TextWrapper) ⇒ CommandHelpFormat

Returns a new instance of CommandHelpFormat.



7
8
9
10
11
12
13
# File 'lib/gli/commands/help_modules/command_help_format.rb', line 7

def initialize(command,app,sorter,synopsis_formatter_class,wrapper_class=TextWrapper)
  @app = app
  @command = command
  @sorter = sorter
  @wrapper_class = wrapper_class
  @synopsis_formatter = synopsis_formatter_class.new(@app,flags_and_switches(@command,@app))
end

Instance Method Details

#formatObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gli/commands/help_modules/command_help_format.rb', line 15

def format
  command_wrapper      = @wrapper_class.new(Terminal.instance.size[0],4 + @command.name.to_s.size + 3)
  wrapper              = @wrapper_class.new(Terminal.instance.size[0],4)
  
  options_description  = OptionsFormatter.new(flags_and_switches(@command,@app),@sorter,@wrapper_class).format
  commands_description = format_subcommands(@command)
  command_examples = format_examples(@command)

  synopses = @synopsis_formatter.synopses_for_command(@command)
  COMMAND_HELP.result(binding)
end