Module: AppSendr::Command
- Extended by:
- Helpers
- Defined in:
- lib/appsendr/command.rb,
lib/appsendr/commands/app.rb,
lib/appsendr/commands/auth.rb,
lib/appsendr/commands/base.rb,
lib/appsendr/commands/help.rb,
lib/appsendr/commands/build.rb,
lib/appsendr/commands/common.rb,
lib/appsendr/commands/deploy.rb,
lib/appsendr/commands/groups.rb,
lib/appsendr/commands/portal.rb,
lib/appsendr/commands/testers.rb,
lib/appsendr/commands/version.rb,
lib/appsendr/commands/collaborators.rb
Defined Under Namespace
Classes: App, Auth, Base, Build, Collaborators, CommandFailed, Deploy, Groups, Help, InvalidCommand, Ipa, Portal, Testers, Version
Class Method Summary
collapse
Methods included from Helpers
credentials_file, credentials_setup?, display, error, has_project_droppr?, home_directory, in_project_dir?, is_file_to_large?, message, project_appsendr, project_appsendr_app, read_app, read_app_id, require_in_project_and_no_droppr, require_project, require_project_dir, require_project_droppr, running_on_a_mac?, running_on_windows?, size_of_file
Class Method Details
.parse(command) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/appsendr/command.rb', line 58
def parse(command)
parts = command.split(':')
case parts.size
when 1
begin
return eval("AppSendr::Command::#{command.capitalize}"), :index
rescue NameError, NoMethodError
return AppSendr::Command::App, command.to_sym
end
else
begin
const = AppSendr::Command
command = parts.pop
parts.each { |part| const = const.const_get(part.capitalize) }
return const, command.to_sym
rescue NameError
raise InvalidCommand
end
end
end
|
.run(command, args, retries = 0) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/appsendr/command.rb', line 17
def run(command, args, retries=0)
begin
run_internal 'auth:login', args.dup if (retries > 0 or !credentials_setup?)
run_internal(command, args.dup)
rescue InvalidCommand
error "Unknown command. Run 'appsendr help' for usage information."
rescue RestClient::Unauthorized
if retries < 3
STDERR.puts "Authentication failure"
run(command, args, retries+1)
else
error "Authentication failure"
end
rescue RestClient::ResourceNotFound
error "Record not found. Are you allowed to access this record?"
rescue RestClient::RequestFailed => e
begin
response = JSON.parse(e.http_body)
display "=== Errors"
response['message'].each{|err|
display err.join(" ")
}
rescue
error "Something went wrong with the server."
end
rescue CommandFailed => e
error e.message
rescue Interrupt => e
error "\n[canceled]"
rescue Exception => e
error e
end
end
|
.run_internal(command, args, appsendr = nil) ⇒ Object
51
52
53
54
55
56
|
# File 'lib/appsendr/command.rb', line 51
def run_internal(command, args, appsendr=nil)
klass, method = parse(command)
runner = klass.new(args, appsendr)
raise InvalidCommand unless runner.respond_to?(method)
runner.send(method)
end
|