Class: Topicz::Commands::HelpCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/topicz/commands/help_command.rb

Instance Method Summary collapse

Constructor Details

#initialize(config_file = nil, arguments = []) ⇒ HelpCommand

Returns a new instance of HelpCommand.



7
8
9
10
11
12
13
14
15
# File 'lib/topicz/commands/help_command.rb', line 7

def initialize(config_file = nil, arguments = [])
  option_parser.order! arguments
  @help =
      if arguments == nil || arguments.empty?
        self
      else
        Topicz::CommandFactory.new.load_command(arguments.shift).new
      end.option_parser
end

Instance Method Details

#executeObject



27
28
29
# File 'lib/topicz/commands/help_command.rb', line 27

def execute
  puts @help.help
end

#option_parserObject



17
18
19
20
21
22
23
24
25
# File 'lib/topicz/commands/help_command.rb', line 17

def option_parser
  OptionParser.new do |options|
    options.banner = 'Usage: help <command>'
    options.separator ''
    options.separator 'Shows help about a specific command. Valid commands are:'
    options.separator ''
    options.separator Topicz::COMMANDS.to_s
  end
end