Sha256: 2ad38810550120b4a3489bd68104ad8c039913d5982d5fcf6e56a57312d384dd

Contents?: true

Size: 750 Bytes

Versions: 4

Compression:

Stored size: 750 Bytes

Contents

require 'topicz/command_factory'

module Topicz::Commands

  class HelpCommand

    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

    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

    def execute
      puts @help.help
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
topicz-0.3.0 lib/topicz/commands/help_command.rb
topicz-0.2.0 lib/topicz/commands/help_command.rb
topicz-0.1.1 lib/topicz/commands/help_command.rb
topicz-0.1.0 lib/topicz/commands/help_command.rb