Sha256: 673dc9baf31b9723a176a4fc5489de4355601234a5f7637165bef9a41d614d27

Contents?: true

Size: 949 Bytes

Versions: 1

Compression:

Stored size: 949 Bytes

Contents

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

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 "Unknown command. Run 'relish help' for usage information."
      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.0.9 lib/relish/command.rb