rhc 1.6.8 → 1.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. data/autocomplete/rhc_bash +1167 -0
  2. data/features/README.md +1 -1
  3. data/features/domain.feature +1 -1
  4. data/features/lib/rhc_helper/persistable.rb +4 -1
  5. data/features/multiple_cartridge.feature +4 -3
  6. data/features/sshkey.feature +3 -3
  7. data/features/support/assumptions.rb +3 -3
  8. data/features/support/env.rb +10 -0
  9. data/features/support/platform_support.rb +2 -2
  10. data/lib/rhc.rb +6 -0
  11. data/lib/rhc/auth/token.rb +4 -0
  12. data/lib/rhc/autocomplete.rb +50 -52
  13. data/lib/rhc/autocomplete_templates/{rhc.erb → bash.erb} +8 -2
  14. data/lib/rhc/cartridge_helpers.rb +1 -1
  15. data/lib/rhc/cli.rb +1 -7
  16. data/lib/rhc/command_runner.rb +45 -16
  17. data/lib/rhc/commands.rb +75 -55
  18. data/lib/rhc/commands/account.rb +7 -51
  19. data/lib/rhc/commands/alias.rb +26 -17
  20. data/lib/rhc/commands/app.rb +75 -39
  21. data/lib/rhc/commands/authorization.rb +4 -2
  22. data/lib/rhc/commands/base.rb +31 -29
  23. data/lib/rhc/commands/cartridge.rb +66 -44
  24. data/lib/rhc/commands/domain.rb +20 -8
  25. data/lib/rhc/commands/git_clone.rb +3 -3
  26. data/lib/rhc/commands/logout.rb +51 -0
  27. data/lib/rhc/commands/port_forward.rb +15 -11
  28. data/lib/rhc/commands/setup.rb +25 -0
  29. data/lib/rhc/commands/snapshot.rb +20 -10
  30. data/lib/rhc/commands/sshkey.rb +21 -7
  31. data/lib/rhc/commands/tail.rb +2 -2
  32. data/lib/rhc/commands/threaddump.rb +2 -2
  33. data/lib/rhc/context_helper.rb +0 -4
  34. data/lib/rhc/core_ext.rb +96 -76
  35. data/lib/rhc/exceptions.rb +6 -0
  36. data/lib/rhc/help_formatter.rb +19 -2
  37. data/lib/rhc/helpers.rb +32 -194
  38. data/lib/rhc/highline_extensions.rb +412 -0
  39. data/lib/rhc/output_helpers.rb +31 -67
  40. data/lib/rhc/rest.rb +4 -2
  41. data/lib/rhc/rest/alias.rb +0 -2
  42. data/lib/rhc/rest/application.rb +9 -4
  43. data/lib/rhc/rest/authorization.rb +0 -2
  44. data/lib/rhc/rest/base.rb +1 -1
  45. data/lib/rhc/rest/client.rb +11 -9
  46. data/lib/rhc/rest/domain.rb +5 -1
  47. data/lib/rhc/rest/gear_group.rb +0 -2
  48. data/lib/rhc/rest/key.rb +0 -2
  49. data/lib/rhc/rest/mock.rb +32 -10
  50. data/lib/rhc/ssh_helpers.rb +2 -2
  51. data/lib/rhc/usage_templates/command_help.erb +20 -13
  52. data/lib/rhc/usage_templates/command_syntax_help.erb +1 -3
  53. data/lib/rhc/usage_templates/help.erb +15 -16
  54. data/lib/rhc/usage_templates/options_help.erb +7 -9
  55. data/lib/rhc/wizard.rb +193 -159
  56. data/spec/rest_spec_helper.rb +2 -2
  57. data/spec/rhc/cli_spec.rb +36 -5
  58. data/spec/rhc/command_spec.rb +94 -42
  59. data/spec/rhc/commands/account_spec.rb +1 -75
  60. data/spec/rhc/commands/alias_spec.rb +28 -28
  61. data/spec/rhc/commands/app_spec.rb +141 -33
  62. data/spec/rhc/commands/apps_spec.rb +4 -4
  63. data/spec/rhc/commands/authorization_spec.rb +8 -8
  64. data/spec/rhc/commands/cartridge_spec.rb +18 -9
  65. data/spec/rhc/commands/domain_spec.rb +16 -16
  66. data/spec/rhc/commands/git_clone_spec.rb +3 -3
  67. data/spec/rhc/commands/logout_spec.rb +86 -0
  68. data/spec/rhc/commands/port_forward_spec.rb +9 -9
  69. data/spec/rhc/commands/server_spec.rb +5 -5
  70. data/spec/rhc/commands/setup_spec.rb +19 -5
  71. data/spec/rhc/commands/snapshot_spec.rb +12 -12
  72. data/spec/rhc/commands/sshkey_spec.rb +11 -11
  73. data/spec/rhc/commands/tail_spec.rb +5 -5
  74. data/spec/rhc/commands/threaddump_spec.rb +3 -3
  75. data/spec/rhc/config_spec.rb +6 -6
  76. data/spec/rhc/helpers_spec.rb +72 -219
  77. data/spec/rhc/highline_extensions_spec.rb +269 -0
  78. data/spec/rhc/rest_application_spec.rb +28 -1
  79. data/spec/rhc/rest_client_spec.rb +20 -21
  80. data/spec/rhc/rest_spec.rb +10 -0
  81. data/spec/rhc/wizard_spec.rb +72 -32
  82. data/spec/spec_helper.rb +86 -56
  83. data/spec/wizard_spec_helper.rb +7 -4
  84. metadata +165 -160
  85. data/spec/spec.opts +0 -1
@@ -5,35 +5,57 @@ module RHC::Commands
5
5
  class Cartridge < Base
6
6
  summary "Manage your application cartridges"
7
7
  syntax "<action>"
8
+ description <<-DESC
9
+ Cartridges add functionality to OpenShift applications. Each application
10
+ has one web cartridge to listen for HTTP requests, and any number
11
+ of addon cartridges. Addons may include databases like MySQL and Mongo,
12
+ administrative tools like phpMyAdmin, or build clients like Jenkins.
13
+
14
+ Most cartridges that listen for incoming network traffic are placed on
15
+ one or more gears (a small server instance). Other cartridges may be
16
+ available across all of the gears of an application to listen for changes
17
+ (like Jenkins) or provide environment variables.
18
+
19
+ Use the 'cartridges' command to see a list of all available cartridges.
20
+ Add a new cartridge to your application with 'add-cartridge'.
21
+
22
+ For scalable applications, use the 'cartridge-scale' command on the web
23
+ cartridge to set the minimum and maximum scale.
24
+
25
+ Commands that affect a cartridge within an application will affect all
26
+ gears the cartridge is installed to.
27
+ DESC
8
28
  alias_action :"app cartridge", :root_command => true, :deprecated => true
9
29
  default_action :list
10
30
 
11
31
  summary "List available cartridges"
12
32
  option ["-v", "--verbose"], "Display more details about each cartridge"
13
33
  alias_action :"app cartridge list", :root_command => true, :deprecated => true
34
+ alias_action :"cartridges", :root_command => true
14
35
  def list
15
36
  carts = rest_client.cartridges.sort_by{ |c| "#{c.type == 'standalone' && 1}_#{c.tags.include?('experimental') ? 1 : 0}_#{(c.display_name || c.name).downcase}" }
16
37
 
17
- list = if options.verbose
18
- carts.map do |c|
19
- name = c.display_name != c.name && "#{color(c.display_name, :cyan)} [#{c.name}]" || c.name
20
- tags = c.tags - RHC::Rest::Cartridge::HIDDEN_TAGS
21
- [
22
- underline("#{name} (#{c.only_in_new? ? 'web' : 'addon'})"),
23
- c.description,
24
- tags.present? ? "\nTagged with: #{tags.sort.join(', ')}" : nil,
25
- c.usage_rate? ? "\n#{format_usage_message(c)}" : nil,
26
- ].compact << "\n"
27
- end.flatten
38
+ pager
39
+
40
+ if options.verbose
41
+ carts.each do |c|
42
+ paragraph do
43
+ name = c.display_name != c.name && "#{color(c.display_name, :cyan)} [#{c.name}]" || c.name
44
+ tags = c.tags - RHC::Rest::Cartridge::HIDDEN_TAGS
45
+ say header([name, "(#{c.only_in_new? ? 'web' : 'addon'})"])
46
+ say c.description
47
+ paragraph{ say "Tagged with: #{tags.sort.join(', ')}" } if tags.present?
48
+ paragraph{ say format_usage_message(c) } if c.usage_rate?
49
+ end
50
+ end
28
51
  else
29
- table(carts.collect do |c|
52
+ say table(carts.collect do |c|
30
53
  [c.usage_rate? ? "#{c.name} (*)" : c.name,
31
54
  c.display_name,
32
55
  c.only_in_new? ? 'web' : 'addon']
33
56
  end)
34
57
  end
35
58
 
36
- say list.join("\n")
37
59
  paragraph{ say "Note: Web cartridges can only be added to new applications." }
38
60
  paragraph{ say "(*) denotes a cartridge with additional usage costs." } if carts.any? { |c| c.usage_rate? }
39
61
 
@@ -41,9 +63,9 @@ module RHC::Commands
41
63
  end
42
64
 
43
65
  summary "Add a cartridge to your application"
44
- syntax "<cartridge_type> [--namespace namespace] [--app app]"
45
- option ["-n", "--namespace namespace"], "Namespace of the application you are adding the cartridge to", :context => :namespace_context, :required => true
46
- option ["-a", "--app app"], "Application you are adding the cartridge to", :context => :app_context, :required => true
66
+ syntax "<cartridge_type> [--namespace NAME] [--app NAME]"
67
+ option ["-n", "--namespace NAME"], "Namespace of the application you are adding the cartridge to", :context => :namespace_context, :required => true
68
+ option ["-a", "--app NAME"], "Application you are adding the cartridge to", :context => :app_context, :required => true
47
69
  argument :cart_type, "The type of the cartridge you are adding (run 'rhc cartridge list' to obtain a list of available cartridges)", ["-c", "--cartridge cart_type"]
48
70
  alias_action :"app cartridge add", :root_command => true, :deprecated => true
49
71
  def add(cart_type)
@@ -66,9 +88,9 @@ module RHC::Commands
66
88
  end
67
89
 
68
90
  summary "Show useful information about a cartridge"
69
- syntax "<cartridge> [--namespace namespace] [--app app]"
70
- option ["-n", "--namespace namespace"], "Namespace of the application you are adding the cartridge to", :context => :namespace_context, :required => true
71
- option ["-a", "--app app"], "Application you are adding the cartridge to", :context => :app_context, :required => true
91
+ syntax "<cartridge> [--namespace NAME] [--app NAME]"
92
+ option ["-n", "--namespace NAME"], "Namespace of the application you are adding the cartridge to", :context => :namespace_context, :required => true
93
+ option ["-a", "--app NAME"], "Application you are adding the cartridge to", :context => :app_context, :required => true
72
94
  argument :cartridge, "The name of the cartridge", ["-c", "--cartridge cart_type"]
73
95
  def show(cartridge)
74
96
  rest_app = rest_client.find_application(options.namespace, options.app, :include => :cartridges)
@@ -80,10 +102,10 @@ module RHC::Commands
80
102
  end
81
103
 
82
104
  summary "Remove a cartridge from your application"
83
- syntax "<cartridge> [--namespace namespace] [--app app]"
105
+ syntax "<cartridge> [--namespace NAME] [--app NAME]"
84
106
  argument :cartridge, "The name of the cartridge you are removing", ["-c", "--cartridge cartridge"]
85
- option ["-n", "--namespace namespace"], "Namespace of the application you are removing the cartridge from", :context => :namespace_context, :required => true
86
- option ["-a", "--app app"], "Application you are removing the cartridge from", :context => :app_context, :required => true
107
+ option ["-n", "--namespace NAME"], "Namespace of the application you are removing the cartridge from", :context => :namespace_context, :required => true
108
+ option ["-a", "--app NAME"], "Application you are removing the cartridge from", :context => :app_context, :required => true
87
109
  option ["--confirm"], "Pass to confirm removing the cartridge"
88
110
  alias_action :"app cartridge remove", :root_command => true, :deprecated => true
89
111
  def remove(cartridge)
@@ -100,10 +122,10 @@ module RHC::Commands
100
122
  end
101
123
 
102
124
  summary "Start a cartridge"
103
- syntax "<cartridge> [--namespace namespace] [--app app]"
125
+ syntax "<cartridge> [--namespace NAME] [--app NAME]"
104
126
  argument :cart_type, "The name of the cartridge you are stopping", ["-c", "--cartridge cartridge"]
105
- option ["-n", "--namespace namespace"], "Namespace of the application the cartrdige belongs to", :context => :namespace_context, :required => true
106
- option ["-a", "--app app"], "Application the cartridge", :context => :app_context, :required => true
127
+ option ["-n", "--namespace NAME"], "Namespace of the application the cartrdige belongs to", :context => :namespace_context, :required => true
128
+ option ["-a", "--app NAME"], "Application the cartridge", :context => :app_context, :required => true
107
129
  alias_action :"app cartridge start", :root_command => true, :deprecated => true
108
130
  def start(cartridge)
109
131
  cartridge_action(cartridge, :start){ |_, c| results{ say "#{c.name} started" } }
@@ -111,10 +133,10 @@ module RHC::Commands
111
133
  end
112
134
 
113
135
  summary "Stop a cartridge"
114
- syntax "<cartridge> [--namespace namespace] [--app app]"
136
+ syntax "<cartridge> [--namespace NAME] [--app NAME]"
115
137
  argument :cart_type, "The name of the cartridge you are stopping", ["-c", "--cartridge cartridge"]
116
- option ["-n", "--namespace namespace"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
117
- option ["-a", "--app app"], "Application you the cartridge belongs to", :context => :app_context, :required => true
138
+ option ["-n", "--namespace NAME"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
139
+ option ["-a", "--app NAME"], "Application you the cartridge belongs to", :context => :app_context, :required => true
118
140
  alias_action :"app cartridge stop", :root_command => true, :deprecated => true
119
141
  def stop(cartridge)
120
142
  cartridge_action(cartridge, :stop){ |_, c| results{ say "#{c.name} stopped" } }
@@ -122,10 +144,10 @@ module RHC::Commands
122
144
  end
123
145
 
124
146
  summary "Restart a cartridge"
125
- syntax "<cartridge_type> [--namespace namespace] [--app app]"
147
+ syntax "<cartridge_type> [--namespace NAME] [--app NAME]"
126
148
  argument :cart_type, "The name of the cartridge you are restarting", ["-c", "--cartridge cartridge"]
127
- option ["-n", "--namespace namespace"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
128
- option ["-a", "--app app"], "Application the cartridge belongs to", :context => :app_context, :required => true
149
+ option ["-n", "--namespace NAME"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
150
+ option ["-a", "--app NAME"], "Application the cartridge belongs to", :context => :app_context, :required => true
129
151
  alias_action :"app cartridge restart", :root_command => true, :deprecated => true
130
152
  def restart(cartridge)
131
153
  cartridge_action(cartridge, :restart){ |_, c| results{ say "#{c.name} restarted" } }
@@ -133,10 +155,10 @@ module RHC::Commands
133
155
  end
134
156
 
135
157
  summary "Get current the status of a cartridge"
136
- syntax "<cartridge> [--namespace namespace] [--app app]"
158
+ syntax "<cartridge> [--namespace NAME] [--app NAME]"
137
159
  argument :cart_type, "The name of the cartridge you are getting the status of", ["-c", "--cartridge cartridge"]
138
- option ["-n", "--namespace namespace"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
139
- option ["-a", "--app app"], "Application the cartridge belongs to", :context => :app_context, :required => true
160
+ option ["-n", "--namespace NAME"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
161
+ option ["-a", "--app NAME"], "Application the cartridge belongs to", :context => :app_context, :required => true
140
162
  alias_action :"app cartridge status", :root_command => true, :deprecated => true
141
163
  def status(cartridge)
142
164
  rest_app = rest_client.find_application(options.namespace, options.app, :include => :cartridges)
@@ -146,10 +168,10 @@ module RHC::Commands
146
168
  end
147
169
 
148
170
  summary "Reload the cartridge's configuration"
149
- syntax "<cartridge> [--namespace namespace] [--app app]"
171
+ syntax "<cartridge> [--namespace NAME] [--app NAME]"
150
172
  argument :cart_type, "The name of the cartridge you are reloading", ["-c", "--cartridge cartridge"]
151
- option ["-n", "--namespace namespace"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
152
- option ["-a", "--app app"], "Application the cartridge belongs to", :context => :app_context, :required => true
173
+ option ["-n", "--namespace NAME"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
174
+ option ["-a", "--app NAME"], "Application the cartridge belongs to", :context => :app_context, :required => true
153
175
  alias_action :"app cartridge reload", :root_command => true, :deprecated => true
154
176
  def reload(cartridge)
155
177
  cartridge_action(cartridge, :reload){ |_, c| results{ say "#{c.name} reloaded" } }
@@ -157,10 +179,10 @@ module RHC::Commands
157
179
  end
158
180
 
159
181
  summary "Set the scaling range of a cartridge"
160
- syntax "<cartridge> [--namespace namespace] [--app app] [--min min] [--max max]"
182
+ syntax "<cartridge> [--namespace NAME] [--app NAME] [--min min] [--max max]"
161
183
  argument :cart_type, "The name of the cartridge you are reloading", ["-c", "--cartridge cartridge"]
162
- option ["-n", "--namespace namespace"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
163
- option ["-a", "--app app"], "Application the cartridge belongs to", :context => :app_context, :required => true
184
+ option ["-n", "--namespace NAME"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
185
+ option ["-a", "--app NAME"], "Application the cartridge belongs to", :context => :app_context, :required => true
164
186
  option ["--min min", Integer], "Minimum scaling value"
165
187
  option ["--max max", Integer], "Maximum scaling value"
166
188
  def scale(cartridge)
@@ -185,10 +207,10 @@ module RHC::Commands
185
207
  end
186
208
 
187
209
  summary 'View/manipulate storage on a cartridge'
188
- syntax '<cartridge> -a app [--show] [--add|--remove|--set amount] [--namespace namespace]'
210
+ syntax '<cartridge> -a app [--show] [--add|--remove|--set amount] [--namespace NAME]'
189
211
  argument :cart_type, "The name of the cartridge", ["-c", "--cartridge cart_type"], :arg_type => :list
190
- option ["-n", "--namespace namespace"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
191
- option ["-a", "--app app"], "Application the cartridge belongs to", :context => :app_context, :required => true
212
+ option ["-n", "--namespace NAME"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
213
+ option ["-a", "--app NAME"], "Application the cartridge belongs to", :context => :app_context, :required => true
192
214
  option ["--show"], "Show the current base and additional storage capacity"
193
215
  option ["--add amount"], "Add the indicated amount to the additional storage capacity"
194
216
  option ["--remove amount"], "Remove the indicated amount from the additional storage capacity"
@@ -196,7 +218,7 @@ module RHC::Commands
196
218
  option ["-f", "--force"], "Force the action"
197
219
  def storage(cartridge)
198
220
  cartridges = Array(cartridge)
199
- rest_app = rest_client.find_application(options.namespace, options.app, :include => :cartridges)
221
+ rest_app = rest_client(:min_api => 1.3).find_application(options.namespace, options.app, :include => :cartridges)
200
222
 
201
223
  # Pull the desired action
202
224
  #
@@ -2,13 +2,24 @@ require 'rhc/commands/base'
2
2
 
3
3
  module RHC::Commands
4
4
  class Domain < Base
5
- summary "Manage the domain and namespace for your applications."
5
+ summary "Add or rename the container for your apps"
6
6
  syntax "<action>"
7
+ description <<-DESC
8
+ OpenShift groups applications within a domain. Each domain has a namespace value
9
+ that will be used as part of the public URL for an application.
10
+
11
+ For example, when creating a domain with the namespace "test", any applications
12
+ created in that domain will have the public URL:
13
+
14
+ http://<appname>-test.rhcloud.com
15
+
16
+ Today, each account may have a single domain.
17
+ DESC
7
18
  default_action :show
8
19
 
9
20
  summary "Define a namespace for your applications to share."
10
21
  syntax "<namespace>"
11
- argument :namespace, "Namespace for your application(s) (alphanumeric)", ["-n", "--namespace namespace"]
22
+ argument :namespace, "Namespace for your application(s) (alphanumeric)", ["-n", "--namespace NAME"]
12
23
  def create(namespace)
13
24
  paragraph { say "Creating domain with namespace '#{namespace}'" }
14
25
  rest_client.add_domain(namespace)
@@ -24,8 +35,8 @@ module RHC::Commands
24
35
  summary "Change current namespace (will change application urls)"
25
36
  syntax "<old namespace> <new namespace>"
26
37
  argument :old_namespace, "Old namespace to change", []
27
- argument :new_namespace, "New namespace to change", ["-n", "--namespace namespace"]
28
- alias_action :alter
38
+ argument :new_namespace, "New namespace to change", ["-n", "--namespace NAME"]
39
+ alias_action :alter, :deprecated => true
29
40
  def update(old_namespace, new_namespace)
30
41
  domain = rest_client.find_domain(old_namespace)
31
42
 
@@ -73,12 +84,12 @@ module RHC::Commands
73
84
 
74
85
  summary "Deletes your domain."
75
86
  syntax "<namespace>"
76
- argument :namespace, "Namespace you wish to destroy", ["-n", "--namespace namespace"]
77
- alias_action :destroy
87
+ argument :namespace, "Namespace you wish to destroy", ["-n", "--namespace NAME"]
88
+ alias_action :destroy, :deprecated => true
78
89
  def delete(namespace)
79
90
  domain = rest_client.find_domain namespace
80
91
 
81
- say "Deleting domain '#{namespace}'"
92
+ say "Deleting domain '#{namespace}' ... "
82
93
 
83
94
  begin
84
95
  domain.destroy
@@ -86,7 +97,8 @@ module RHC::Commands
86
97
  raise RHC::Exception.new("Domain contains applications. Delete applications first.", 128)
87
98
  end
88
99
 
89
- results { say "Success!" }
100
+ success "deleted"
101
+
90
102
  0
91
103
  end
92
104
  end
@@ -7,10 +7,10 @@ module RHC::Commands
7
7
  description "This is a convenience wrapper for 'git clone' with the added",
8
8
  "benefit of adding configuration data such as the application's",
9
9
  "UUID to the local repository. It also automatically",
10
- "figures out the git url from the application name so you don't",
10
+ "figures out the Git url from the application name so you don't",
11
11
  "have to look it up."
12
- syntax "<app> [--namespace namespace]"
13
- option ["-n", "--namespace namespace"], "Namespace of the application", :context => :namespace_context, :required => true
12
+ syntax "<app> [--namespace NAME]"
13
+ option ["-n", "--namespace NAME"], "Namespace of the application", :context => :namespace_context, :required => true
14
14
  option ["-r", "--repo dir"], "Path to the Git repository (defaults to ./$app_name)"
15
15
  argument :app, "The application you wish to clone", ["-a", "--app name"]
16
16
  alias_action 'app git-clone', :deprecated => true, :root_command => true
@@ -0,0 +1,51 @@
1
+ module RHC::Commands
2
+ class Logout < Base
3
+ suppress_wizard
4
+
5
+ summary "End the current session"
6
+ description <<-DESC
7
+ Logout ends your current session on the server and then removes
8
+ all of the local session files. If you are using multiple
9
+ servers and configurations this will remove all of your local
10
+ session files.
11
+
12
+ The --all option will terminate all authorizations on your
13
+ account. Any previously generated authorizations will be
14
+ deleted and external tools that integrate with your account
15
+ will no longer be able to log in.
16
+ DESC
17
+ option '--all', "Remove all authorizations on your account."
18
+ alias_action 'account logout', :root_command => true
19
+ def run
20
+ if options.all
21
+ rest_client.user # force authentication
22
+ say "Deleting all authorizations associated with your account ... "
23
+ begin
24
+ rest_client.delete_authorizations
25
+ success "done"
26
+ rescue RHC::Rest::AuthorizationsNotSupported
27
+ info "not supported"
28
+ end
29
+ elsif token_for_user
30
+ options.noprompt = true
31
+ say "Ending session on server ... "
32
+ begin
33
+ rest_client.delete_authorization(token_for_user)
34
+ success "deleted"
35
+ rescue RHC::Rest::AuthorizationsNotSupported
36
+ info "not supported"
37
+ rescue RHC::Rest::TokenExpiredOrInvalid
38
+ info "already closed"
39
+ rescue => e
40
+ debug_error(e)
41
+ warn e.message
42
+ end
43
+ end
44
+
45
+ 0
46
+ ensure
47
+ token_store.clear
48
+ success "All local sessions removed."
49
+ end
50
+ end
51
+ end
@@ -70,8 +70,8 @@ module RHC::Commands
70
70
 
71
71
  summary "Forward remote ports to the workstation"
72
72
  syntax "<application>"
73
- option ["-n", "--namespace namespace"], "Namespace of the application you are port forwarding to", :context => :namespace_context, :required => true
74
- argument :app, "Application you are port forwarding to (required)", ["-a", "--app app"]
73
+ option ["-n", "--namespace NAME"], "Namespace of the application you are port forwarding to", :context => :namespace_context, :required => true
74
+ argument :app, "Application you are port forwarding to (required)", ["-a", "--app NAME"]
75
75
  def run(app)
76
76
  rest_app = rest_client.find_application(options.namespace, app)
77
77
 
@@ -81,7 +81,7 @@ module RHC::Commands
81
81
  forwarding_specs = []
82
82
 
83
83
  begin
84
- say "Checking available ports..."
84
+ say "Checking available ports ... "
85
85
 
86
86
  Net::SSH.start(ssh_uri.host, ssh_uri.user) do |ssh|
87
87
  ssh.exec! "rhc-list-ports" do |channel, stream, data|
@@ -119,9 +119,11 @@ module RHC::Commands
119
119
  end
120
120
  end
121
121
 
122
+ success "done"
123
+
122
124
  begin
123
125
  Net::SSH.start(ssh_uri.host, ssh_uri.user) do |ssh|
124
- say "Forwarding ports"
126
+ say "Forwarding ports ..."
125
127
  forwarding_specs.each do |fs|
126
128
  given_up = nil
127
129
  while !fs.bound? && !given_up
@@ -141,13 +143,15 @@ module RHC::Commands
141
143
 
142
144
  bound_ports = forwarding_specs.select(&:bound?)
143
145
  if bound_ports.length > 0
144
- paragraph {
145
- say "To connect to a service running on OpenShift, use the Local address"
146
- }
147
- items = bound_ports.map do |fs|
148
- [fs.service, "#{fs.host_from}:#{fs.port_from}", " => ", "#{fs.remote_host}:#{fs.port_to.to_s}"]
146
+ paragraph{ say "To connect to a service running on OpenShift, use the Local address" }
147
+ paragraph do
148
+ say table(
149
+ bound_ports.map do |fs|
150
+ [fs.service, "#{fs.host_from}:#{fs.port_from}", " => ", "#{fs.remote_host}:#{fs.port_to.to_s}"]
151
+ end,
152
+ :header => ["Service", "Local", " ", "OpenShift"]
153
+ )
149
154
  end
150
- table(items, :header => ["Service", "Local", " ", "OpenShift"]).each { |s| success " #{s}" }
151
155
  end
152
156
 
153
157
  # for failed port forwarding attempts
@@ -167,7 +171,7 @@ module RHC::Commands
167
171
  ssh.loop { true }
168
172
  end
169
173
  rescue Interrupt
170
- results { say "Ending port forward" }
174
+ say " Ending port forward"
171
175
  return 0
172
176
  end
173
177
 
@@ -23,11 +23,36 @@ module RHC::Commands
23
23
 
24
24
  If the server supports authorization tokens, you may pass the
25
25
  --create-token option to instruct the wizard to generate a key for you.
26
+
27
+ If you would like to enable tab-completion in Bash shells, pass
28
+ --autocomplete for more information.
26
29
  DESC
27
30
  option ["--server NAME"], "Hostname of an OpenShift server", :context => :server_context, :required => true
28
31
  option ['--clean'], "Ignore any saved configuration options"
29
32
  option ['--[no-]create-token'], "Create an authorization token for this server"
33
+ option ['--autocomplete'], "Instructions for enabling tab-completion"
30
34
  def run
35
+ if options.autocomplete
36
+ src = File.join(File.join(Gem.loaded_specs['rhc'].full_gem_path, "autocomplete"), "rhc_bash")
37
+ dest = File.join(RHC::Config.home_conf_dir, "bash_autocomplete")
38
+
39
+ FileUtils.mkdir_p(RHC::Config.home_conf_dir)
40
+ FileUtils.cp(src, dest)
41
+
42
+ say <<-LINE.strip_heredoc
43
+ To enable tab-completion for RHC under Bash shells, add the following command to
44
+ your .bashrc or .bash_profile file:
45
+
46
+ . #{dest}
47
+
48
+ Save your shell and then restart. Type "rhc" and then hit the TAB key twice to
49
+ trigger completion of your command.
50
+
51
+ Tab-completion is not available in the Windows terminal.
52
+ LINE
53
+ return 0
54
+ end
55
+
31
56
  raise OptionParser::InvalidOption, "Setup can not be run with the --noprompt option" if options.noprompt
32
57
  RHC::RerunWizard.new(config, options).run ? 0 : 1
33
58
  end
@@ -4,14 +4,24 @@ module RHC::Commands
4
4
  class Snapshot < Base
5
5
  summary "Save the current state of your application locally"
6
6
  syntax "<action>"
7
+ description <<-DESC
8
+ Snapshots allow you to export the current state of your OpenShift application
9
+ into an archive on your local system, and then to restore it later.
10
+
11
+ The snapshot archive contains the Git repository, dumps of any attached databases,
12
+ and any other information that the cartridges decide to export.
13
+
14
+ WARNING: Both 'save' and 'restore' will stop the application and then restart
15
+ after the operation completes.
16
+ DESC
7
17
  alias_action :"app snapshot", :root_command => true
8
18
  default_action :help
9
19
 
10
- summary "Pull down application snapshot for the specified application."
11
- syntax "<application>"
12
- option ["-n", "--namespace namespace"], "Namespace of the application you are saving a snapshot", :context => :namespace_context, :required => true
13
- option ["-f", "--filepath filepath"], "Local path to save tarball (default: ./$APPNAME.tar.gz)"
14
- argument :app, "Application you are saving a snapshot (required)", ["-a", "--app app"]
20
+ summary "Save a snapshot of your app to disk"
21
+ syntax "<application> [--filepath FILE]"
22
+ option ["-n", "--namespace NAME"], "Namespace of the application you are saving a snapshot", :context => :namespace_context, :required => true
23
+ option ["-f", "--filepath FILE"], "Local path to save tarball (default: ./$APPNAME.tar.gz)"
24
+ argument :app, "Application you are saving a snapshot", ["-a", "--app NAME"]
15
25
  alias_action :"app snapshot save", :root_command => true, :deprecated => true
16
26
  def save(app)
17
27
  rest_app = rest_client.find_application(options.namespace, app)
@@ -52,11 +62,11 @@ module RHC::Commands
52
62
  0
53
63
  end
54
64
 
55
- summary "Restores a previously saved snapshot."
56
- syntax "<application>"
57
- option ["-n", "--namespace namespace"], "Namespace of the application you are restoring a snapshot", :context => :namespace_context, :required => true
58
- option ["-f", "--filepath filepath"], "Local path to restore tarball"
59
- argument :app, "Application of which you are restoring a snapshot (required)", ["-a", "--app app"]
65
+ summary "Restores a previously saved snapshot"
66
+ syntax "<application> [--filepath FILE]"
67
+ option ["-n", "--namespace NAME"], "Namespace of the application you are restoring a snapshot", :context => :namespace_context, :required => true
68
+ option ["-f", "--filepath FILE"], "Local path to restore tarball"
69
+ argument :app, "Application of which you are restoring a snapshot", ["-a", "--app NAME"]
60
70
  alias_action :"app snapshot restore", :root_command => true, :deprecated => true
61
71
  def restore(app)
62
72