lib/relish/command.rb in relish-0.0.8 vs lib/relish/command.rb in relish-0.0.9
- old
+ new
@@ -1,22 +1,40 @@
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
- def self.run(command, args)
- command_class, method = get_command_and_method(command, args)
- command_class.new(args).send(method)
- end
+ 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 self.get_command_and_method(command, args)
- command_class, method = command.split(':')
- return Relish::Command.const_get(command_class.capitalize), (method || :default)
+ 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
\ No newline at end of file