acquia_toolbelt 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data/.gitignore +7 -0
  2. data/.ruby-version +1 -0
  3. data/.travis.yml +7 -0
  4. data/CONTRIBUTING.md +11 -0
  5. data/Gemfile +3 -0
  6. data/Gemfile.lock +55 -0
  7. data/Guardfile +5 -0
  8. data/LICENSE +19 -0
  9. data/README.md +149 -0
  10. data/Rakefile +1 -0
  11. data/acquia_toolbelt.gemspec +34 -0
  12. data/bin/acquia +9 -0
  13. data/lib/acquia_toolbelt/cli/api.rb +164 -0
  14. data/lib/acquia_toolbelt/cli/auth.rb +31 -0
  15. data/lib/acquia_toolbelt/cli/database.rb +237 -0
  16. data/lib/acquia_toolbelt/cli/deploy.rb +36 -0
  17. data/lib/acquia_toolbelt/cli/domain.rb +177 -0
  18. data/lib/acquia_toolbelt/cli/environment.rb +71 -0
  19. data/lib/acquia_toolbelt/cli/file.rb +31 -0
  20. data/lib/acquia_toolbelt/cli/server.rb +67 -0
  21. data/lib/acquia_toolbelt/cli/site.rb +28 -0
  22. data/lib/acquia_toolbelt/cli/ssh.rb +78 -0
  23. data/lib/acquia_toolbelt/cli/svn.rb +73 -0
  24. data/lib/acquia_toolbelt/cli/task.rb +74 -0
  25. data/lib/acquia_toolbelt/cli/ui.rb +44 -0
  26. data/lib/acquia_toolbelt/cli.rb +103 -0
  27. data/lib/acquia_toolbelt/error.rb +4 -0
  28. data/lib/acquia_toolbelt/thor.rb +95 -0
  29. data/lib/acquia_toolbelt/version.rb +3 -0
  30. data/lib/acquia_toolbelt.rb +4 -0
  31. data/lib/vendor/thor/CHANGELOG.md +139 -0
  32. data/lib/vendor/thor/Gemfile +20 -0
  33. data/lib/vendor/thor/LICENSE.md +20 -0
  34. data/lib/vendor/thor/README.md +35 -0
  35. data/lib/vendor/thor/lib/thor/actions/create_file.rb +105 -0
  36. data/lib/vendor/thor/lib/thor/actions/create_link.rb +60 -0
  37. data/lib/vendor/thor/lib/thor/actions/directory.rb +119 -0
  38. data/lib/vendor/thor/lib/thor/actions/empty_directory.rb +137 -0
  39. data/lib/vendor/thor/lib/thor/actions/file_manipulation.rb +317 -0
  40. data/lib/vendor/thor/lib/thor/actions/inject_into_file.rb +109 -0
  41. data/lib/vendor/thor/lib/thor/actions.rb +318 -0
  42. data/lib/vendor/thor/lib/thor/base.rb +654 -0
  43. data/lib/vendor/thor/lib/thor/command.rb +136 -0
  44. data/lib/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +80 -0
  45. data/lib/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
  46. data/lib/vendor/thor/lib/thor/core_ext/ordered_hash.rb +100 -0
  47. data/lib/vendor/thor/lib/thor/error.rb +32 -0
  48. data/lib/vendor/thor/lib/thor/group.rb +282 -0
  49. data/lib/vendor/thor/lib/thor/invocation.rb +172 -0
  50. data/lib/vendor/thor/lib/thor/parser/argument.rb +74 -0
  51. data/lib/vendor/thor/lib/thor/parser/arguments.rb +171 -0
  52. data/lib/vendor/thor/lib/thor/parser/option.rb +121 -0
  53. data/lib/vendor/thor/lib/thor/parser/options.rb +218 -0
  54. data/lib/vendor/thor/lib/thor/parser.rb +4 -0
  55. data/lib/vendor/thor/lib/thor/rake_compat.rb +72 -0
  56. data/lib/vendor/thor/lib/thor/runner.rb +322 -0
  57. data/lib/vendor/thor/lib/thor/shell/basic.rb +422 -0
  58. data/lib/vendor/thor/lib/thor/shell/color.rb +148 -0
  59. data/lib/vendor/thor/lib/thor/shell/html.rb +127 -0
  60. data/lib/vendor/thor/lib/thor/shell.rb +88 -0
  61. data/lib/vendor/thor/lib/thor/util.rb +270 -0
  62. data/lib/vendor/thor/lib/thor/version.rb +3 -0
  63. data/lib/vendor/thor/lib/thor.rb +474 -0
  64. data/lib/vendor/thor/spec/actions/create_file_spec.rb +170 -0
  65. data/lib/vendor/thor/spec/actions/create_link_spec.rb +95 -0
  66. data/lib/vendor/thor/spec/actions/directory_spec.rb +169 -0
  67. data/lib/vendor/thor/spec/actions/empty_directory_spec.rb +129 -0
  68. data/lib/vendor/thor/spec/actions/file_manipulation_spec.rb +382 -0
  69. data/lib/vendor/thor/spec/actions/inject_into_file_spec.rb +135 -0
  70. data/lib/vendor/thor/spec/actions_spec.rb +331 -0
  71. data/lib/vendor/thor/spec/base_spec.rb +291 -0
  72. data/lib/vendor/thor/spec/command_spec.rb +80 -0
  73. data/lib/vendor/thor/spec/core_ext/hash_with_indifferent_access_spec.rb +48 -0
  74. data/lib/vendor/thor/spec/core_ext/ordered_hash_spec.rb +115 -0
  75. data/lib/vendor/thor/spec/exit_condition_spec.rb +19 -0
  76. data/lib/vendor/thor/spec/fixtures/application.rb +2 -0
  77. data/lib/vendor/thor/spec/fixtures/app{1}/README +3 -0
  78. data/lib/vendor/thor/spec/fixtures/bundle/execute.rb +6 -0
  79. data/lib/vendor/thor/spec/fixtures/bundle/main.thor +1 -0
  80. data/lib/vendor/thor/spec/fixtures/command.thor +10 -0
  81. data/lib/vendor/thor/spec/fixtures/doc/%file_name%.rb.tt +1 -0
  82. data/lib/vendor/thor/spec/fixtures/doc/COMMENTER +11 -0
  83. data/lib/vendor/thor/spec/fixtures/doc/README +3 -0
  84. data/lib/vendor/thor/spec/fixtures/doc/block_helper.rb +3 -0
  85. data/lib/vendor/thor/spec/fixtures/doc/components/.empty_directory +0 -0
  86. data/lib/vendor/thor/spec/fixtures/doc/config.rb +1 -0
  87. data/lib/vendor/thor/spec/fixtures/doc/config.yaml.tt +1 -0
  88. data/lib/vendor/thor/spec/fixtures/doc/excluding/%file_name%.rb.tt +1 -0
  89. data/lib/vendor/thor/spec/fixtures/enum.thor +10 -0
  90. data/lib/vendor/thor/spec/fixtures/group.thor +128 -0
  91. data/lib/vendor/thor/spec/fixtures/invoke.thor +118 -0
  92. data/lib/vendor/thor/spec/fixtures/path with spaces +0 -0
  93. data/lib/vendor/thor/spec/fixtures/preserve/script.sh +3 -0
  94. data/lib/vendor/thor/spec/fixtures/script.thor +220 -0
  95. data/lib/vendor/thor/spec/fixtures/subcommand.thor +17 -0
  96. data/lib/vendor/thor/spec/group_spec.rb +222 -0
  97. data/lib/vendor/thor/spec/helper.rb +67 -0
  98. data/lib/vendor/thor/spec/invocation_spec.rb +108 -0
  99. data/lib/vendor/thor/spec/parser/argument_spec.rb +53 -0
  100. data/lib/vendor/thor/spec/parser/arguments_spec.rb +66 -0
  101. data/lib/vendor/thor/spec/parser/option_spec.rb +202 -0
  102. data/lib/vendor/thor/spec/parser/options_spec.rb +400 -0
  103. data/lib/vendor/thor/spec/rake_compat_spec.rb +72 -0
  104. data/lib/vendor/thor/spec/register_spec.rb +197 -0
  105. data/lib/vendor/thor/spec/runner_spec.rb +241 -0
  106. data/lib/vendor/thor/spec/shell/basic_spec.rb +330 -0
  107. data/lib/vendor/thor/spec/shell/color_spec.rb +95 -0
  108. data/lib/vendor/thor/spec/shell/html_spec.rb +31 -0
  109. data/lib/vendor/thor/spec/shell_spec.rb +47 -0
  110. data/lib/vendor/thor/spec/subcommand_spec.rb +30 -0
  111. data/lib/vendor/thor/spec/thor_spec.rb +499 -0
  112. data/lib/vendor/thor/spec/util_spec.rb +196 -0
  113. data/lib/vendor/thor/thor.gemspec +24 -0
  114. data/script/release +50 -0
  115. data/script/setup_build +6 -0
  116. data/script/test +23 -0
  117. data/spec/auth_spec.rb +15 -0
  118. data/spec/cassettes/databases/all_databases.json +1 -0
  119. data/spec/cassettes/databases/copy_database_from_dev_to_stage.json +1 -0
  120. data/spec/cassettes/databases/create_a_database_backup.json +1 -0
  121. data/spec/cassettes/databases/create_a_new_database.json +1 -0
  122. data/spec/cassettes/databases/delete_a_database.json +1 -0
  123. data/spec/cassettes/databases/get_all_existing_databases.json +1 -0
  124. data/spec/cassettes/databases/list_all_database_backups.json +1 -0
  125. data/spec/cassettes/databases/view_database_instance_details.json +1 -0
  126. data/spec/cassettes/deploy/release_vcs_branch.json +1 -0
  127. data/spec/cassettes/domains/create_new_domain.json +1 -0
  128. data/spec/cassettes/domains/delete_a_domain.json +1 -0
  129. data/spec/cassettes/domains/get_all_existing_domains.json +1 -0
  130. data/spec/cassettes/domains/list_all_dev_domains.json +1 -0
  131. data/spec/cassettes/domains/move_from_dev_to_stage.json +1 -0
  132. data/spec/cassettes/domains/purge_varnish_cache.json +1 -0
  133. data/spec/cassettes/environments/all_environments.json +1 -0
  134. data/spec/cassettes/environments/disable_live_development.json +1 -0
  135. data/spec/cassettes/environments/enable_live_development.json +1 -0
  136. data/spec/cassettes/files/copy_from_dev_to_stage.json +1 -0
  137. data/spec/cassettes/servers/all_dev_servers.json +1 -0
  138. data/spec/cassettes/servers/all_prod_servers.json +1 -0
  139. data/spec/cassettes/sites/all_sites.json +1 -0
  140. data/spec/cassettes/ssh/all_sshkeys.json +1 -0
  141. data/spec/cassettes/svn/all_svnusers.json +1 -0
  142. data/spec/cassettes/tasks/all_tasks.json +1 -0
  143. data/spec/databases_spec.rb +78 -0
  144. data/spec/deploy_spec.rb +12 -0
  145. data/spec/domains_spec.rb +59 -0
  146. data/spec/environments_spec.rb +35 -0
  147. data/spec/files_spec.rb +11 -0
  148. data/spec/helper.rb +104 -0
  149. data/spec/servers_spec.rb +59 -0
  150. data/spec/sites_spec.rb +19 -0
  151. data/spec/ssh_spec.rb +19 -0
  152. data/spec/svn_spec.rb +11 -0
  153. data/spec/tasks_spec.rb +11 -0
  154. metadata +158 -4
@@ -0,0 +1,78 @@
1
+ require "sshkey"
2
+
3
+ module AcquiaToolbelt
4
+ class CLI
5
+ class SSH < AcquiaToolbelt::Thor
6
+ # Public: List all SSH users.
7
+ #
8
+ # Returns a list of users and their SSH keys truncated.
9
+ desc "list", "List all SSH users."
10
+ def list
11
+ if options[:subscription]
12
+ subscription = options[:subscription]
13
+ else
14
+ subscription = AcquiaToolbelt::CLI::API.default_subscription
15
+ end
16
+
17
+ users = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/sshkeys"
18
+ users.each do |user|
19
+ say
20
+ say "> ID: #{user["id"]}"
21
+ say "> Name: #{user["nickname"]}"
22
+ say "> Fingerprint: #{SSHKey.fingerprint user["ssh_pub_key"]}"
23
+ end
24
+ end
25
+
26
+ # Public: Delete a SSH key.
27
+ #
28
+ # Returns a status message.
29
+ desc "delete", "Delete a SSH key."
30
+ method_option :id, :type => :string, :aliases => %w(-i), :required => true,
31
+ :desc => "User ID to delete from SSH users."
32
+ def delete
33
+ if options[:subscription]
34
+ subscription = options[:subscription]
35
+ else
36
+ subscription = AcquiaToolbelt::CLI::API.default_subscription
37
+ end
38
+
39
+ id = options[:id]
40
+
41
+ delete_ssh_request = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/sshkeys/#{id}", "DELETE"
42
+
43
+ if delete_ssh_request["id"]
44
+ ui.success "SSH key #{id} has been successfully deleted."
45
+ else
46
+ ui.fail AcquiaToolbelt::CLI::API.display_error(delete_ssh_key)
47
+ end
48
+ end
49
+
50
+ # Public: Add a SSH key to a subscription.
51
+ #
52
+ # Returns a status message.
53
+ desc "add", "Add a SSH key."
54
+ method_option :nickname, :type => :string, :aliases => %w(-n), :required => true,
55
+ :desc => "Nickname to ."
56
+ method_option :key, :type => :string, :aliases => %w(-k), :required => true,
57
+ :desc => "Public SSH key to add."
58
+ def add
59
+ if options[:subscription]
60
+ subscription = options[:subscription]
61
+ else
62
+ subscription = AcquiaToolbelt::CLI::API.default_subscription
63
+ end
64
+
65
+ key = options[:key]
66
+ nickname = options[:nickname]
67
+ data = { :key => "nickname", :value => "#{nickname}", :ssh_pub_key => "#{key}" }
68
+
69
+ add_ssh_key = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/sshkeys", "QUERY-STRING-POST", data
70
+ if add_ssh_key["id"]
71
+ ui.success "SSH key '#{nickname}' has been successfully added."
72
+ else
73
+ ui.fail AcquiaToolbelt::CLI::API.display_error(add_ssh_key)
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,73 @@
1
+ module AcquiaToolbelt
2
+ class CLI
3
+ class SVN < AcquiaToolbelt::Thor
4
+ # Public: List all SVN users.
5
+ #
6
+ # Returns a list of available users.
7
+ desc "list", "List all SVN users."
8
+ def list
9
+ if options[:subscription]
10
+ subscription = options[:subscription]
11
+ else
12
+ subscription = AcquiaToolbelt::CLI::API.default_subscription
13
+ end
14
+
15
+ svn_users = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/svnusers"
16
+ svn_users.each do |user|
17
+ ui.say
18
+ ui.say "> ID: #{user["id"]}"
19
+ ui.say "> Name: #{user["username"]}"
20
+ end
21
+ end
22
+
23
+ # Public: Create a new SVN user.
24
+ #
25
+ # Returns a status message.
26
+ desc "add", "Add a SVN user."
27
+ method_option :username, :type => :string, :aliases => %w(-u), :required => true,
28
+ :desc => "Username you wish to set."
29
+ method_option :password, :type => :string, :aliases => %w(-p), :required => true,
30
+ :desc => "Password you wish to set."
31
+ def add
32
+ if options[:subscription]
33
+ subscription = options[:subscription]
34
+ else
35
+ subscription = AcquiaToolbelt::CLI::API.default_subscription
36
+ end
37
+
38
+ username = options[:username]
39
+ password = options[:password]
40
+
41
+ add_svn_user = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/svnusers/#{username}", "POST", :password => "#{password}"
42
+ if add_svn_user["id"]
43
+ ui.success "User '#{username}' has been successfully created."
44
+ else
45
+ ui.fail AcquiaToolbelt::CLI::API.display_error(add_svn_user)
46
+ end
47
+ end
48
+
49
+ # Public: Delete a SVN user.
50
+ #
51
+ # Returns a status message.
52
+ desc "delete", "Delete an SVN user."
53
+ method_option :id, :type => :string, :aliases => %w(-i), :required => true,
54
+ :desc => "User ID to delete from SVN users."
55
+ def delete
56
+ if options[:subscription]
57
+ subscription = options[:subscription]
58
+ else
59
+ subscription = AcquiaToolbelt::CLI::API.default_subscription
60
+ end
61
+
62
+ userid = options[:id]
63
+
64
+ svn_user_removal = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/svnusers/#{userid}", "DELETE"
65
+ if svn_user_removal["id"]
66
+ ui.success "#{userid} has been removed from the SVN users."
67
+ else
68
+ ui.fail AcquiaToolbelt::CLI::API.display_error(svn_user_removal)
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,74 @@
1
+ module AcquiaToolbelt
2
+ class CLI
3
+ class Tasks < AcquiaToolbelt::Thor
4
+ no_tasks do
5
+ # Internal: Output information for a single task item.
6
+ #
7
+ # task - The task object that contains all the information about the
8
+ # task.
9
+ def output_task_item(task)
10
+ completion_time = (task["completed"].to_i - task["started"].to_i) / 60
11
+ ui.say
12
+ ui.say "Task ID: #{task["id"].to_i}"
13
+ ui.say "Description: #{task["description"]}"
14
+ ui.say "Status: #{task["state"]}"
15
+
16
+ # If the completion time is greater then 0, output it in minutes
17
+ # otherwise just say it was less then a minute.
18
+ if completion_time > 0
19
+ ui.say "Compeletion time: About #{completion_time} minutes"
20
+ else
21
+ ui.say "Compeletion time: Less than 1 minute"
22
+ end
23
+
24
+ ui.say "Queue: #{task["queue"]}"
25
+ end
26
+ end
27
+
28
+ # Public: List all tasks from the Acquia tasks queue(s).
29
+ #
30
+ # Returns a task listing.
31
+ desc "list", "List all tasks."
32
+ method_option :queue, :type => :string, :aliases => %w(-q),
33
+ :desc => "Task queue to target."
34
+ method_option :count, :type => :string, :aliases => %w(-c),
35
+ :desc => "Limit the tasks returned."
36
+ def list
37
+ if options[:subscription]
38
+ subscription = options[:subscription]
39
+ else
40
+ subscription = AcquiaToolbelt::CLI::API.default_subscription
41
+ end
42
+
43
+ queue = options[:queue]
44
+ count = options[:count]
45
+
46
+ all_tasks = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/tasks"
47
+ tasks = []
48
+
49
+ # Fetch a single queue from the tasks list if the queue parameter is set
50
+ # otherwise just add all the tasks.
51
+ if queue
52
+ all_tasks.each do |task|
53
+ if task["queue"] == queue
54
+ tasks << task
55
+ end
56
+ end
57
+ else
58
+ all_tasks.each do |task|
59
+ tasks << task
60
+ end
61
+ end
62
+
63
+ # If there is a count to return, restrict it to that required amount.
64
+ if count && tasks.any?
65
+ tasks = tasks.last(count.to_i)
66
+ end
67
+
68
+ tasks.each do |task|
69
+ output_task_item(task)
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,44 @@
1
+ require "highline/import"
2
+ require "rainbow"
3
+
4
+ module AcquiaToolbelt
5
+ class CLI
6
+ class UI < Thor::Base.shell
7
+ # Internal: Used for outputting a pretty success message.
8
+ #
9
+ # text - The text to run through and output to the end user.
10
+ #
11
+ # Returns the string coloured and formatted.
12
+ def success(text)
13
+ puts "#{text}".foreground(:green)
14
+ end
15
+
16
+ # Internal: Used for outputting a pretty error message.
17
+ #
18
+ # text - The text to run through and output to the end user.
19
+ #
20
+ # Returns the string coloured and formatted.
21
+ def fail(text)
22
+ puts "#{text}".foreground(:red)
23
+ end
24
+
25
+ # Internal: Used for outputting a pretty info message.
26
+ #
27
+ # text - The text to run through and output to the end user.
28
+ #
29
+ # Returns the string coloured and formatted.
30
+ def info(text)
31
+ puts "#{text}".foreground(:cyan)
32
+ end
33
+
34
+ # Internal: Used for outputting a pretty debug message.
35
+ #
36
+ # text - The text to run through and output to the end user.
37
+ #
38
+ # Returns the string coloured and formatted.
39
+ def debug(text)
40
+ puts "#{text}".foreground(:yellow)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,103 @@
1
+ require "acquia_toolbelt"
2
+ require "acquia_toolbelt/error"
3
+ require "acquia_toolbelt/thor"
4
+
5
+ module AcquiaToolbelt
6
+ class CLI < AcquiaToolbelt::Thor
7
+ require "acquia_toolbelt/cli/ui"
8
+ require "acquia_toolbelt/cli/api"
9
+ require "acquia_toolbelt/cli/auth"
10
+ require "acquia_toolbelt/cli/database"
11
+ require "acquia_toolbelt/cli/server"
12
+ require "acquia_toolbelt/cli/ssh"
13
+ require "acquia_toolbelt/cli/svn"
14
+ require "acquia_toolbelt/cli/task"
15
+ require "acquia_toolbelt/cli/site"
16
+ require "acquia_toolbelt/cli/domain"
17
+ require "acquia_toolbelt/cli/deploy"
18
+ require "acquia_toolbelt/cli/file"
19
+ require "acquia_toolbelt/cli/environment"
20
+
21
+ include Thor::Actions
22
+
23
+ def self.start(given_args = ARGV, config = {})
24
+ Thor::Base.shell = AcquiaToolbelt::CLI::UI
25
+ ui = AcquiaToolbelt::CLI::UI.new
26
+
27
+ # Use a custom symbol to separate the commands. Useful for rake styled
28
+ # commands.
29
+ if given_args[0].include? ":"
30
+ commands = given_args.shift.split(":")
31
+ given_args = given_args.unshift(commands).flatten
32
+ end
33
+
34
+ super(given_args, {:shell => ui}.merge(config))
35
+ rescue AcquiaToolbelt::Error
36
+ ui.print_exception(e)
37
+ raise
38
+ rescue Interrupt => e
39
+ puts
40
+ ui.print_exception(e)
41
+ ui.say("Quitting...")
42
+ raise
43
+ rescue SystemExit, Errno::EPIPE
44
+ # Don't print a message for safe exits.
45
+ raise
46
+ rescue Exception => e
47
+ ui.print_exception(e)
48
+ raise
49
+ end
50
+
51
+ # Define some options that are available to all commands.
52
+ class_option :subscription, :type => :string, :aliases => %w(-s),
53
+ :desc => "Name of a subscription you would like to target."
54
+ class_option :environment, :type => :string, :aliases => %w(-e),
55
+ :desc => "Environment to target for commands."
56
+ class_option :verbose, :type => :boolean, :aliases => %w(-v),
57
+ :desc => "Increase the verbose output from the commands."
58
+
59
+ # Authentication.
60
+ desc "auth", ""
61
+ subcommand "auth", AcquiaToolbelt::CLI::Auth
62
+
63
+ # Databases.
64
+ desc "databases", ""
65
+ subcommand "databases", AcquiaToolbelt::CLI::Databases
66
+
67
+ # Servers.
68
+ desc "servers", ""
69
+ subcommand "servers", AcquiaToolbelt::CLI::Servers
70
+
71
+ # SSH.
72
+ desc "ssh", ""
73
+ subcommand "ssh", AcquiaToolbelt::CLI::SSH
74
+
75
+ # SVN.
76
+ desc "svn", ""
77
+ subcommand "svn", AcquiaToolbelt::CLI::SVN
78
+
79
+ # Tasks.
80
+ desc "tasks", ""
81
+ subcommand "tasks", AcquiaToolbelt::CLI::Tasks
82
+
83
+ # Sites.
84
+ desc "sites", ""
85
+ subcommand "sites", AcquiaToolbelt::CLI::Sites
86
+
87
+ # Domains.
88
+ desc "domains", ""
89
+ subcommand "domains", AcquiaToolbelt::CLI::Domains
90
+
91
+ # Deployments.
92
+ desc "deploy", ""
93
+ subcommand "deploy", AcquiaToolbelt::CLI::Deploy
94
+
95
+ # Files.
96
+ desc "files", ""
97
+ subcommand "files", AcquiaToolbelt::CLI::Files
98
+
99
+ # Environments.
100
+ desc "environments", ""
101
+ subcommand "environments", AcquiaToolbelt::CLI::Environments
102
+ end
103
+ end
@@ -0,0 +1,4 @@
1
+ module AcquiaToolbelt
2
+ class Error < RuntimeError
3
+ end
4
+ end
@@ -0,0 +1,95 @@
1
+ $:.unshift(File.expand_path('../vendor/thor/lib/', File.dirname(__FILE__)))
2
+ require 'thor'
3
+
4
+ module AcquiaToolbelt
5
+ module UtilityMethods
6
+ protected
7
+
8
+ # Alias Thor's shell to UI instead.
9
+ def ui
10
+ shell
11
+ end
12
+ end
13
+
14
+ class Thor < ::Thor
15
+ include UtilityMethods
16
+ no_tasks do
17
+ def self.help(shell, subcommand = false)
18
+ list = printable_commands(true, subcommand).sort!{ |a,b| a[0] <=> b[0] }
19
+
20
+ shell.say "Type 'acquia [COMMAND] help' for more details on subcommands or to show example usage."
21
+
22
+ if @package_name
23
+ shell.say "#{@package_name} commands:"
24
+ else
25
+ shell.say
26
+ shell.say "Commands:"
27
+ end
28
+
29
+ shell.print_table(list, :indent => 2, :truncate => true)
30
+ shell.say unless subcommand
31
+ class_options_help(shell)
32
+ end
33
+
34
+ def self.printable_commands(all = true, subcommand = true)
35
+ (all ? all_commands : commands).map do |_, command|
36
+ # Don't show the hidden commands or the help commands.
37
+ next if command.hidden? || next if command.name.include? 'help'
38
+ item = []
39
+ item << banner(command, false, subcommand)
40
+ item << (command.description ? "# #{command.description.gsub(/\s+/m,' ')}" : "") unless command.description.empty?
41
+ item
42
+ end.compact
43
+ end
44
+
45
+ # Define a base for the commands.
46
+ def self.banner_base
47
+ "acquia"
48
+ end
49
+
50
+ def self.banner(task, task_help = false, subcommand = false)
51
+ subcommand_banner = to_s.split(/::/).map{|s| s.downcase}[2..-1]
52
+ subcommand_banner = if subcommand_banner.size > 0
53
+ subcommand_banner.join(" ")
54
+ else
55
+ nil
56
+ end
57
+
58
+ task = (task_help ? task.formatted_usage(self, false, subcommand) : task.name)
59
+ banner_base + " " + [subcommand_banner, task].compact.join(":")
60
+ end
61
+
62
+ def self.handle_no_task_error(task)
63
+ raise UndefinedTaskError, "Could not find command #{task.inspect}."
64
+ end
65
+
66
+ def self.subcommand(name, klass)
67
+ @@subcommand_class_for ||= {}
68
+ @@subcommand_class_for[name] = klass
69
+ super
70
+ end
71
+
72
+ def self.subcommand_class_for(name)
73
+ @@subcommand_class_for ||= {}
74
+ @@subcommand_class_for[name]
75
+ end
76
+
77
+ end
78
+
79
+ protected
80
+
81
+ def self.exit_on_failure?
82
+ true
83
+ end
84
+ end
85
+
86
+ # Patch handle_no_method_error? to work with rubinius' error text.
87
+ class ::Thor::Task
88
+ def handle_no_method_error?(instance, error, caller)
89
+ not_debugging?(instance) && (
90
+ error.message =~ /^undefined method `#{name}' for #{Regexp.escape(instance.to_s)}$/ ||
91
+ error.message =~ /undefined method `#{name}' on an instance of #{Regexp.escape(instance.class.name)}/
92
+ )
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,3 @@
1
+ module AcquiaToolbelt
2
+ VERSION = '2.3.1'
3
+ end
@@ -0,0 +1,4 @@
1
+ require "acquia_toolbelt/version"
2
+
3
+ module AcquiaToolbelt
4
+ end
@@ -0,0 +1,139 @@
1
+ ## 0.18.1, release 2013-03-30
2
+ * Revert regressions found in 0.18.0
3
+
4
+ ## 0.18.0, release 2013-03-26
5
+ * Remove rake2thor
6
+ * Only display colors if output medium supports colors
7
+ * Pass parent_options to subcommands
8
+ * Fix non-dash-prefixed aliases
9
+ * Make error messages more helpful
10
+ * Rename "task" to "command"
11
+ * Add the method to allow for custom package name
12
+
13
+ ## 0.17.0, release 2013-01-24
14
+ * Add better support for tasks that accept arbitrary additional arguments (e.g. things like `bundle exec`)
15
+ * Add #stop_on_unknown_option!
16
+ * Only strip from stdin.gets if it wasn't ended with EOF
17
+ * Allow "send" as a task name
18
+ * Allow passing options as arguments after "--"
19
+ * Autoload Thor::Group
20
+
21
+ ## 0.16.0, release 2012-08-14
22
+ * Add enum to string arguments
23
+
24
+ ## 0.15.4, release 2012-06-29
25
+ * Fix regression when destination root contains reserved regexp characters
26
+
27
+ ## 0.15.3, release 2012-06-18
28
+ * Support strict_args_position! for backwards compatibility
29
+ * Escape Dir glob characters in paths
30
+
31
+ ## 0.15.2, released 2012-05-07
32
+ * Added print_in_columns
33
+ * Exposed terminal_width as a public API
34
+
35
+ ## 0.15.1, release 2012-05-06
36
+ * Fix Ruby 1.8 truncation bug with unicode chars
37
+ * Fix shell delegate methods to pass their block
38
+ * Don't output trailing spaces when printing the last column in a table
39
+
40
+ ## 0.15, released 2012-04-29
41
+ * Alias method_options to options
42
+ * Refactor say to allow multiple colors
43
+ * Exposed error as a public API
44
+ * Exposed file_collision as a public API
45
+ * Exposed print_wrapped as a public API
46
+ * Exposed set_color as a public API
47
+ * Fix number-formatting bugs in print_table
48
+ * Fix "indent" typo in print_table
49
+ * Fix Errno::EPIPE when piping tasks to `head`
50
+ * More friendly error messages
51
+
52
+ ## 0.14, released 2010-07-25
53
+ * Added CreateLink class and #link_file method
54
+ * Made Thor::Actions#run use system as default method for system calls
55
+ * Allow use of private methods from superclass as tasks
56
+ * Added mute(&block) method which allows to run block without any output
57
+ * Removed config[:pretend]
58
+ * Enabled underscores for command line switches
59
+ * Added Thor::Base.basename which is used by both Thor.banner and Thor::Group.banner
60
+ * Deprecated invoke() without arguments
61
+ * Added :only and :except to check_unknown_options
62
+
63
+ ## 0.13, released 2010-02-03
64
+ * Added :lazy_default which is only triggered if a switch is given
65
+ * Added Thor::Shell::HTML
66
+ * Added subcommands
67
+ * Decoupled Thor::Group and Thor, so it's easier to vendor
68
+ * Added check_unknown_options! in case you want error messages to be raised in valid switches
69
+ * run(command) should return the results of command
70
+
71
+ ## 0.12, released 2010-01-02
72
+ * Methods generated by attr_* are automatically not marked as tasks
73
+ * inject_into_file does not add the same content twice, unless :force is set
74
+ * Removed rr in favor to rspec mock framework
75
+ * Improved output for thor -T
76
+ * [#7] Do not force white color on status
77
+ * [#8] Yield a block with the filename on directory
78
+
79
+ ## 0.11, released 2009-07-01
80
+ * Added a rake compatibility layer. It allows you to use spec and rdoc tasks on
81
+ Thor classes.
82
+ * BACKWARDS INCOMPATIBLE: aliases are not generated automatically anymore
83
+ since it may cause wrong behavior in the invocation system.
84
+ * thor help now show information about any class/task. All those calls are
85
+ possible:
86
+
87
+ thor help describe
88
+ thor help describe:amazing
89
+ Or even with default namespaces:
90
+
91
+ thor help :spec
92
+ * Thor::Runner now invokes the default task if none is supplied:
93
+
94
+ thor describe # invokes the default task, usually help
95
+ * Thor::Runner now works with mappings:
96
+
97
+ thor describe -h
98
+ * Added some documentation and code refactoring.
99
+
100
+ ## 0.9.8, released 2008-10-20
101
+ * Fixed some tiny issues that were introduced lately.
102
+
103
+ ## 0.9.7, released 2008-10-13
104
+ * Setting global method options on the initialize method works as expected:
105
+ All other tasks will accept these global options in addition to their own.
106
+ * Added 'group' notion to Thor task sets (class Thor); by default all tasks
107
+ are in the 'standard' group. Running 'thor -T' will only show the standard
108
+ tasks - adding --all will show all tasks. You can also filter on a specific
109
+ group using the --group option: thor -T --group advanced
110
+
111
+ ## 0.9.6, released 2008-09-13
112
+ * Generic improvements
113
+
114
+ ## 0.9.5, released 2008-08-27
115
+ * Improve Windows compatibility
116
+ * Update (incorrect) README and task.thor sample file
117
+ * Options hash is now frozen (once returned)
118
+ * Allow magic predicates on options object. For instance: `options.force?`
119
+ * Add support for :numeric type
120
+ * BACKWARDS INCOMPATIBLE: Refactor Thor::Options. You cannot access shorthand forms in options hash anymore (for instance, options[:f])
121
+ * Allow specifying optional args with default values: method_options(:user => "mislav")
122
+ * Don't write options for nil or false values. This allows, for example, turning color off when running specs.
123
+ * Exit with the status of the spec command to help CI stuff out some.
124
+
125
+ ## 0.9.4, released 2008-08-13
126
+ * Try to add Windows compatibility.
127
+ * BACKWARDS INCOMPATIBLE: options hash is now accessed as a property in your class and is not passed as last argument anymore
128
+ * Allow options at the beginning of the argument list as well as the end.
129
+ * Make options available with symbol keys in addition to string keys.
130
+ * Allow true to be passed to Thor#method_options to denote a boolean option.
131
+ * If loading a thor file fails, don't give up, just print a warning and keep going.
132
+ * Make sure that we re-raise errors if they happened further down the pipe than we care about.
133
+ * Only delete the old file on updating when the installation of the new one is a success
134
+ * Make it Ruby 1.8.5 compatible.
135
+ * Don't raise an error if a boolean switch is defined multiple times.
136
+ * Thor::Options now doesn't parse through things that look like options but aren't.
137
+ * Add URI detection to install task, and make sure we don't append ".thor" to URIs
138
+ * Add rake2thor to the gem binfiles.
139
+ * Make sure local Thorfiles override system-wide ones.
@@ -0,0 +1,20 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake', '>= 0.9'
4
+ gem 'rdoc', '>= 3.9'
5
+
6
+ group :development do
7
+ gem 'pry'
8
+ gem 'pry-debugger', :platforms => :mri_19
9
+ end
10
+
11
+ group :test do
12
+ gem 'childlabor'
13
+ gem 'coveralls', '>=0.5.7', :require => false
14
+ gem 'fakeweb', '>= 1.3'
15
+ gem 'rspec', '>= 2.14'
16
+ gem 'rspec-mocks', '>= 2.12.2'
17
+ gem 'simplecov', :require => false
18
+ end
19
+
20
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Yehuda Katz, Eric Hodel, et al.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.