Class: Winnie::Command
- Inherits:
-
Object
- Object
- Winnie::Command
- Extended by:
- Helpers
- Defined in:
- lib/winnie/command.rb
Defined Under Namespace
Classes: UnknownCommandException
Class Method Summary collapse
Methods included from Helpers
ask, confirm, display, display_columns, error, line
Class Method Details
.run(name, *args) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/winnie/command.rb', line 5 def self.run(name, *args) begin class_name, command_name = name.split(':') command_name ||= 'run' begin command_class = Winnie::Commands.const_get(class_name.capitalize.to_sym) rescue NameError command_class = Winnie::Commands::App command_name = class_name end command = command_class.new(args) if command.respond_to?(command_name) command.send(command_name) else raise UnknownCommandException.new end rescue UnknownCommandException error 'Unknown command' rescue Winnie::Client::UnauthorizedException error "Your API key is not correct\nUse 'winnie auth' command to re-enter your winnie API key" rescue Winnie::Commands::ApplicationNotSpecyfiedException error "Application not specified\nUse --app <code name> to specify the application" rescue Winnie::Client::ResourceNotFoundException, Winnie::Client::CommandFailedException => e error e. end end |