Sha256: 286c49db25863bf24bf090e15068fd36c9c1a2ee5a9319b4e451654191d316fb

Contents?: true

Size: 984 Bytes

Versions: 1

Compression:

Stored size: 984 Bytes

Contents

require 'relish'
require 'relish/helpers'
require 'relish/error_messages'
require 'relish/commands/base'
require 'relish/commands/collab'
require 'relish/commands/config'
require 'relish/commands/help'
require 'relish/commands/projects'
require 'relish/commands/push'

module Relish
  module Command
    
    class << self
      include Relish::Helpers
      
      def run(command, args)
        command_class, method = get_command_and_method(command, args)      
        command_class.new(args).send(method)
      end
    
      def get_command_and_method(command, args)
        command_class, method = command.split(':')
        return get_command(command_class.capitalize), get_method(method)
      rescue NameError
        error ErrorMessages.unknown_command
      end
      
    private
    
      def get_command(command)
        Relish::Command.const_get(command)
      end
      
      def get_method(method)
        method || :default
      end
      
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relish-0.1.3 lib/relish/command.rb