cf 0.1.5 → 0.6.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1277 -30
- data/Rakefile +12 -1
- data/bin/cf +0 -3
- data/lib/cf.rb +6 -0
- data/lib/cf/cli.rb +389 -190
- data/lib/cf/cli/app/app.rb +45 -0
- data/lib/cf/cli/app/apps.rb +99 -0
- data/lib/cf/cli/app/base.rb +90 -0
- data/lib/cf/cli/app/crashes.rb +42 -0
- data/lib/cf/cli/app/delete.rb +95 -0
- data/lib/cf/cli/app/deprecated.rb +11 -0
- data/lib/cf/cli/app/env.rb +78 -0
- data/lib/cf/cli/app/files.rb +137 -0
- data/lib/cf/cli/app/health.rb +26 -0
- data/lib/cf/cli/app/instances.rb +53 -0
- data/lib/cf/cli/app/logs.rb +76 -0
- data/lib/cf/cli/app/push.rb +105 -0
- data/lib/cf/cli/app/push/create.rb +149 -0
- data/lib/cf/cli/app/push/interactions.rb +94 -0
- data/lib/cf/cli/app/push/sync.rb +64 -0
- data/lib/cf/cli/app/rename.rb +35 -0
- data/lib/cf/cli/app/restart.rb +20 -0
- data/lib/cf/cli/app/scale.rb +69 -0
- data/lib/cf/cli/app/start.rb +143 -0
- data/lib/cf/cli/app/stats.rb +67 -0
- data/lib/cf/cli/app/stop.rb +27 -0
- data/lib/cf/cli/domain/base.rb +8 -0
- data/lib/cf/cli/domain/domains.rb +40 -0
- data/lib/cf/cli/domain/map.rb +55 -0
- data/lib/cf/cli/domain/unmap.rb +56 -0
- data/lib/cf/cli/help.rb +15 -0
- data/lib/cf/cli/interactive.rb +105 -0
- data/lib/cf/cli/organization/base.rb +12 -0
- data/lib/cf/cli/organization/create.rb +32 -0
- data/lib/cf/cli/organization/delete.rb +73 -0
- data/lib/cf/cli/organization/org.rb +45 -0
- data/lib/cf/cli/organization/orgs.rb +35 -0
- data/lib/cf/cli/organization/rename.rb +36 -0
- data/lib/cf/cli/route/base.rb +8 -0
- data/lib/cf/cli/route/map.rb +70 -0
- data/lib/cf/cli/route/routes.rb +26 -0
- data/lib/cf/cli/route/unmap.rb +62 -0
- data/lib/cf/cli/service/base.rb +8 -0
- data/lib/cf/cli/service/bind.rb +44 -0
- data/lib/cf/cli/service/create.rb +107 -0
- data/lib/cf/cli/service/delete.rb +82 -0
- data/lib/cf/cli/service/rename.rb +35 -0
- data/lib/cf/cli/service/service.rb +40 -0
- data/lib/cf/cli/service/services.rb +99 -0
- data/lib/cf/cli/service/unbind.rb +38 -0
- data/lib/cf/cli/space/base.rb +19 -0
- data/lib/cf/cli/space/create.rb +63 -0
- data/lib/cf/cli/space/delete.rb +95 -0
- data/lib/cf/cli/space/rename.rb +39 -0
- data/lib/cf/cli/space/space.rb +64 -0
- data/lib/cf/cli/space/spaces.rb +55 -0
- data/lib/cf/cli/space/switch.rb +16 -0
- data/lib/cf/cli/start/base.rb +93 -0
- data/lib/cf/cli/start/colors.rb +13 -0
- data/lib/cf/cli/start/info.rb +124 -0
- data/lib/cf/cli/start/login.rb +94 -0
- data/lib/cf/cli/start/logout.rb +17 -0
- data/lib/cf/cli/start/target.rb +69 -0
- data/lib/cf/cli/start/target_interactions.rb +37 -0
- data/lib/cf/cli/start/targets.rb +16 -0
- data/lib/cf/cli/user/base.rb +29 -0
- data/lib/cf/cli/user/create.rb +39 -0
- data/lib/cf/cli/user/passwd.rb +43 -0
- data/lib/cf/cli/user/register.rb +42 -0
- data/lib/cf/cli/user/users.rb +32 -0
- data/lib/cf/constants.rb +10 -7
- data/lib/cf/detect.rb +113 -48
- data/lib/cf/errors.rb +17 -0
- data/lib/cf/plugin.rb +28 -12
- data/lib/cf/spacing.rb +89 -0
- data/lib/cf/spec_helper.rb +1 -0
- data/lib/cf/test_support.rb +6 -0
- data/lib/cf/version.rb +1 -1
- data/spec/assets/hello-sinatra/Gemfile +3 -0
- data/spec/assets/hello-sinatra/Gemfile.lock +17 -0
- data/spec/assets/hello-sinatra/config.ru +3 -0
- data/spec/assets/hello-sinatra/fat-cat-makes-app-larger.png +0 -0
- data/spec/assets/hello-sinatra/main.rb +6 -0
- data/spec/assets/specker_runner/specker_runner_input.rb +6 -0
- data/spec/assets/specker_runner/specker_runner_pause.rb +5 -0
- data/spec/cf/cli/app/base_spec.rb +17 -0
- data/spec/cf/cli/app/delete_spec.rb +188 -0
- data/spec/cf/cli/app/instances_spec.rb +65 -0
- data/spec/cf/cli/app/push/create_spec.rb +661 -0
- data/spec/cf/cli/app/push_spec.rb +369 -0
- data/spec/cf/cli/app/rename_spec.rb +104 -0
- data/spec/cf/cli/app/scale_spec.rb +75 -0
- data/spec/cf/cli/app/start_spec.rb +208 -0
- data/spec/cf/cli/app/stats_spec.rb +68 -0
- data/spec/cf/cli/domain/map_spec.rb +130 -0
- data/spec/cf/cli/domain/unmap_spec.rb +69 -0
- data/spec/cf/cli/organization/orgs_spec.rb +108 -0
- data/spec/cf/cli/organization/rename_spec.rb +113 -0
- data/spec/cf/cli/route/map_spec.rb +121 -0
- data/spec/cf/cli/route/unmap_spec.rb +155 -0
- data/spec/cf/cli/service/bind_spec.rb +25 -0
- data/spec/cf/cli/service/delete_spec.rb +22 -0
- data/spec/cf/cli/service/rename_spec.rb +105 -0
- data/spec/cf/cli/service/service_spec.rb +23 -0
- data/spec/cf/cli/service/unbind_spec.rb +25 -0
- data/spec/cf/cli/space/create_spec.rb +93 -0
- data/spec/cf/cli/space/rename_spec.rb +102 -0
- data/spec/cf/cli/space/spaces_spec.rb +104 -0
- data/spec/cf/cli/space/switch_space_spec.rb +55 -0
- data/spec/cf/cli/start/info_spec.rb +160 -0
- data/spec/cf/cli/start/login_spec.rb +142 -0
- data/spec/cf/cli/start/logout_spec.rb +50 -0
- data/spec/cf/cli/start/target_spec.rb +123 -0
- data/spec/cf/cli/user/create_spec.rb +54 -0
- data/spec/cf/cli/user/passwd_spec.rb +102 -0
- data/spec/cf/cli/user/register_spec.rb +140 -0
- data/spec/cf/cli_spec.rb +442 -0
- data/spec/cf/detect_spec.rb +54 -0
- data/spec/console_app_specker/console_app_specker_matchers_spec.rb +173 -0
- data/spec/console_app_specker/specker_runner_spec.rb +167 -0
- data/spec/features/account_lifecycle_spec.rb +85 -0
- data/spec/features/login_spec.rb +66 -0
- data/spec/features/push_flow_spec.rb +125 -0
- data/spec/features/switching_targets_spec.rb +32 -0
- data/spec/spec_helper.rb +72 -0
- data/spec/support/command_helper.rb +81 -0
- data/spec/support/config_helper.rb +15 -0
- data/spec/support/console_app_specker_matchers.rb +86 -0
- data/spec/support/fake_home_dir.rb +55 -0
- data/spec/support/interact_helper.rb +29 -0
- data/spec/support/shared_examples/errors.rb +40 -0
- data/spec/support/shared_examples/input.rb +14 -0
- data/spec/support/specker_runner.rb +80 -0
- data/spec/support/tracking_expector.rb +71 -0
- metadata +427 -66
- data/lib/cf/cli/app.rb +0 -595
- data/lib/cf/cli/command.rb +0 -444
- data/lib/cf/cli/dots.rb +0 -133
- data/lib/cf/cli/service.rb +0 -112
- data/lib/cf/cli/user.rb +0 -71
@@ -0,0 +1,27 @@
|
|
1
|
+
require "cf/cli/app/base"
|
2
|
+
|
3
|
+
module CF::App
|
4
|
+
class Stop < Base
|
5
|
+
desc "Stop an application"
|
6
|
+
group :apps, :manage
|
7
|
+
input :apps, :desc => "Applications to start", :argument => :splat,
|
8
|
+
:singular => :app, :from_given => by_name(:app)
|
9
|
+
input :all, :desc => "Stop all applications", :default => false
|
10
|
+
def stop
|
11
|
+
apps = input[:all] ? client.apps : input[:apps]
|
12
|
+
fail "No applications given." if apps.empty?
|
13
|
+
|
14
|
+
apps.each do |app|
|
15
|
+
with_progress("Stopping #{c(app.name, :name)}") do |s|
|
16
|
+
if app.stopped?
|
17
|
+
s.skip do
|
18
|
+
err "Application is not running."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
app.stop!
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "cf/cli/domain/base"
|
2
|
+
|
3
|
+
module CF::Domain
|
4
|
+
class Domains < Base
|
5
|
+
desc "List domains in a space"
|
6
|
+
group :domains
|
7
|
+
input :space, :desc => "Space to list the domains from",
|
8
|
+
:argument => :optional, :default => proc { client.current_space },
|
9
|
+
:from_given => by_name(:space)
|
10
|
+
input :all, :desc => "List all domains", :default => false
|
11
|
+
def domains
|
12
|
+
space = input[:space]
|
13
|
+
|
14
|
+
domains =
|
15
|
+
if input[:all]
|
16
|
+
with_progress("Getting all domains") do
|
17
|
+
client.domains
|
18
|
+
end
|
19
|
+
else
|
20
|
+
with_progress("Getting domains in #{c(space.name, :name)}") do
|
21
|
+
space.domains
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
line unless quiet?
|
26
|
+
|
27
|
+
table(
|
28
|
+
%w{name owner},
|
29
|
+
domains.sort_by(&:name).collect { |r|
|
30
|
+
[c(r.name, :name),
|
31
|
+
if org = r.owning_organization
|
32
|
+
c(org.name, :name)
|
33
|
+
else
|
34
|
+
d("none")
|
35
|
+
end
|
36
|
+
]
|
37
|
+
})
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "cf/cli/domain/base"
|
2
|
+
|
3
|
+
module CF::Domain
|
4
|
+
class Map < Base
|
5
|
+
desc "Map a domain to an organization or space"
|
6
|
+
group :domains
|
7
|
+
input :name, :desc => "Domain to map", :argument => :required
|
8
|
+
input :organization, :desc => "Organization to map the domain to",
|
9
|
+
:aliases => %w{--org -o},
|
10
|
+
:default => proc { client.current_organization },
|
11
|
+
:from_given => by_name(:organization)
|
12
|
+
input :space, :desc => "Space to map the domain to",
|
13
|
+
:default => proc { client.current_space },
|
14
|
+
:from_given => by_name(:space)
|
15
|
+
input :shared, :desc => "Create a shared domain", :default => false
|
16
|
+
def map_domain
|
17
|
+
domain = client.domain_by_name(input[:name])
|
18
|
+
|
19
|
+
given_org = input.has?(:organization)
|
20
|
+
given_space = input.has?(:space)
|
21
|
+
|
22
|
+
org = input[:organization]
|
23
|
+
space = input[:space]
|
24
|
+
|
25
|
+
given_space = true unless given_org || given_space
|
26
|
+
|
27
|
+
unless domain
|
28
|
+
domain = client.domain
|
29
|
+
domain.name = input[:name]
|
30
|
+
domain.owning_organization = org unless input[:shared]
|
31
|
+
domain.wildcard = true
|
32
|
+
|
33
|
+
with_progress("Creating domain #{c(domain.name, :name)}") do
|
34
|
+
domain.create!
|
35
|
+
org.add_domain(domain) if org && !given_org && !given_space
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
if given_space
|
40
|
+
add_domain(domain, space.organization)
|
41
|
+
add_domain(domain, space)
|
42
|
+
elsif given_org
|
43
|
+
add_domain(domain, org)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def add_domain(domain, target)
|
50
|
+
with_progress("Mapping #{c(domain.name, :name)} to #{c(target.name, :name)}") do
|
51
|
+
target.add_domain(domain)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "cf/cli/domain/base"
|
2
|
+
|
3
|
+
module CF::Domain
|
4
|
+
class Unmap < Base
|
5
|
+
desc "Unmap a domain from an organization or space"
|
6
|
+
group :domains
|
7
|
+
input :domain, :desc => "Domain to unmap", :argument => :required,
|
8
|
+
:from_given => by_name("domain")
|
9
|
+
input :organization, :desc => "Organization to unmap the domain from",
|
10
|
+
:aliases => %w{--org -o},
|
11
|
+
:default => proc { client.current_organization },
|
12
|
+
:from_given => by_name(:organization)
|
13
|
+
input :space, :desc => "Space to unmap the domain from",
|
14
|
+
:default => proc { client.current_space },
|
15
|
+
:from_given => by_name(:space)
|
16
|
+
input :delete, :desc => "Delete domain", :type => :boolean
|
17
|
+
input :really, :type => :boolean, :forget => true, :hidden => true,
|
18
|
+
:default => proc { force? || interact }
|
19
|
+
def unmap_domain
|
20
|
+
domain = input[:domain]
|
21
|
+
|
22
|
+
given_org = input.has?(:organization)
|
23
|
+
given_space = input.has?(:space)
|
24
|
+
|
25
|
+
org = input[:organization]
|
26
|
+
space = input[:space]
|
27
|
+
|
28
|
+
if input[:delete]
|
29
|
+
return unless input[:really, domain.name, :name]
|
30
|
+
|
31
|
+
with_progress("Deleting domain #{c(domain.name, :name)}") do
|
32
|
+
domain.delete!
|
33
|
+
end
|
34
|
+
|
35
|
+
return
|
36
|
+
end
|
37
|
+
|
38
|
+
given_space = true unless given_org || given_space
|
39
|
+
|
40
|
+
remove_domain(domain, space) if given_space
|
41
|
+
remove_domain(domain, org) if given_org
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def remove_domain(domain, target)
|
47
|
+
with_progress("Unmapping #{c(domain.name, :name)} from #{c(target.name, :name)}") do
|
48
|
+
target.remove_domain(domain)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def ask_really(name, color)
|
53
|
+
ask("Really delete #{c(name, color)}?", :default => false)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/cf/cli/help.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "mothership/help"
|
2
|
+
|
3
|
+
Mothership::Help.groups(
|
4
|
+
[:start, "Getting Started"],
|
5
|
+
[:apps, "Applications",
|
6
|
+
[:manage, "Management"],
|
7
|
+
[:info, "Information"]],
|
8
|
+
[:services, "Services",
|
9
|
+
[:manage, "Management"]],
|
10
|
+
[:organizations, "Organizations"],
|
11
|
+
[:spaces, "Spaces"],
|
12
|
+
[:routes, "Routes"],
|
13
|
+
[:domains, "Domains"],
|
14
|
+
[:admin, "Administration",
|
15
|
+
[:user, "User Management"]])
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require "interact"
|
2
|
+
require "interact/pretty"
|
3
|
+
require "interact/progress"
|
4
|
+
|
5
|
+
module CF
|
6
|
+
module Interactive
|
7
|
+
include ::Interactive::Rewindable
|
8
|
+
include Interact::Pretty
|
9
|
+
include Interact::Progress
|
10
|
+
|
11
|
+
def ask(question, options = {})
|
12
|
+
if force? and options.key?(:default)
|
13
|
+
options[:default]
|
14
|
+
else
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def list_choices(choices, options = {})
|
20
|
+
choices.each_with_index do |o, i|
|
21
|
+
puts "#{c(i + 1, :number)}: #{show_choice(o, options)}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def input_state(options)
|
26
|
+
if options.key? :default
|
27
|
+
answer = show_default(options)
|
28
|
+
end
|
29
|
+
|
30
|
+
CFState.new(options, answer)
|
31
|
+
end
|
32
|
+
|
33
|
+
def show_default(options)
|
34
|
+
case options[:default]
|
35
|
+
when true
|
36
|
+
"y"
|
37
|
+
when false
|
38
|
+
"n"
|
39
|
+
when nil
|
40
|
+
""
|
41
|
+
else
|
42
|
+
show_choice(options[:default], options)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def prompt(question, options)
|
47
|
+
value = show_default(options)
|
48
|
+
|
49
|
+
print "#{question}"
|
50
|
+
print c("> ", :prompt)
|
51
|
+
|
52
|
+
unless value.empty?
|
53
|
+
print "#{d(value) + "\b" * value.size}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def handler(event, state)
|
58
|
+
ans = state.answer
|
59
|
+
pos = state.position
|
60
|
+
|
61
|
+
exit if event == :eof
|
62
|
+
|
63
|
+
if state.default?
|
64
|
+
if event.is_a?(Array) and event[0] == :key
|
65
|
+
# initial non-movement keypress clears default answer
|
66
|
+
clear_input(state)
|
67
|
+
else
|
68
|
+
# wipe away any coloring
|
69
|
+
redraw_input(state)
|
70
|
+
end
|
71
|
+
|
72
|
+
state.clear_default!
|
73
|
+
|
74
|
+
# tab with a default accepts it and moves to the end
|
75
|
+
if event == :tab
|
76
|
+
state.goto(ans.size)
|
77
|
+
else
|
78
|
+
super
|
79
|
+
end
|
80
|
+
else
|
81
|
+
super
|
82
|
+
end
|
83
|
+
|
84
|
+
print "\n" if event == :enter
|
85
|
+
end
|
86
|
+
|
87
|
+
class CFState < ::Interactive::InputState
|
88
|
+
def initialize(options = {}, answer = nil, position = 0)
|
89
|
+
@options = options
|
90
|
+
@answer = answer || ""
|
91
|
+
@default = options.key? :default
|
92
|
+
@position = position
|
93
|
+
@done = false
|
94
|
+
end
|
95
|
+
|
96
|
+
def clear_default!
|
97
|
+
@default = false
|
98
|
+
end
|
99
|
+
|
100
|
+
def default?
|
101
|
+
@default
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "cf/cli/organization/base"
|
2
|
+
|
3
|
+
module CF::Organization
|
4
|
+
class Create < Base
|
5
|
+
desc "Create an organization"
|
6
|
+
group :organizations
|
7
|
+
input :name, :desc => "Organization name", :argument => :optional
|
8
|
+
input :target, :desc => "Switch to the organization after creation",
|
9
|
+
:alias => "-t", :default => true
|
10
|
+
input :add_self, :desc => "Add yourself to the organization",
|
11
|
+
:default => true
|
12
|
+
def create_org
|
13
|
+
org = client.organization
|
14
|
+
org.name = input[:name]
|
15
|
+
org.users = [client.current_user] if input[:add_self]
|
16
|
+
|
17
|
+
with_progress("Creating organization #{c(org.name, :name)}") do
|
18
|
+
org.create!
|
19
|
+
end
|
20
|
+
|
21
|
+
if input[:target]
|
22
|
+
invoke :target, :organization => org
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def ask_name
|
29
|
+
ask("Name")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require "cf/cli/organization/base"
|
2
|
+
|
3
|
+
module CF::Organization
|
4
|
+
class Delete < Base
|
5
|
+
desc "Delete an organization"
|
6
|
+
group :organizations
|
7
|
+
input :organization, :desc => "Organization to delete",
|
8
|
+
:aliases => %w{--org -o}, :argument => :optional,
|
9
|
+
:from_given => by_name(:organization)
|
10
|
+
input :recursive, :desc => "Delete recursively", :alias => "-r",
|
11
|
+
:default => false, :forget => true
|
12
|
+
input :warn, :desc => "Show warning if it was the last org",
|
13
|
+
:default => true
|
14
|
+
input :really, :type => :boolean, :forget => true, :hidden => true,
|
15
|
+
:default => proc { force? || interact }
|
16
|
+
def delete_org
|
17
|
+
org = input[:organization]
|
18
|
+
return unless input[:really, org]
|
19
|
+
|
20
|
+
spaces = org.spaces
|
21
|
+
unless spaces.empty?
|
22
|
+
unless force?
|
23
|
+
line "This organization is not empty!"
|
24
|
+
line
|
25
|
+
line "spaces: #{name_list(spaces)}"
|
26
|
+
line
|
27
|
+
|
28
|
+
return unless input[:recursive]
|
29
|
+
end
|
30
|
+
|
31
|
+
spaces.each do |s|
|
32
|
+
invoke :delete_space, :space => s, :really => true,
|
33
|
+
:recursive => true, :warn => false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
is_current = org == client.current_organization
|
38
|
+
|
39
|
+
with_progress("Deleting organization #{c(org.name, :name)}") do
|
40
|
+
org.delete!
|
41
|
+
end
|
42
|
+
|
43
|
+
if orgs.size == 1
|
44
|
+
return unless input[:warn]
|
45
|
+
|
46
|
+
line
|
47
|
+
line c("There are no longer any organizations.", :warning)
|
48
|
+
line "You may want to create one with #{c("create-org", :good)}."
|
49
|
+
elsif is_current
|
50
|
+
invalidate_target
|
51
|
+
invoke :target
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def ask_organization
|
58
|
+
orgs = client.organizations
|
59
|
+
fail "No organizations." if orgs.empty?
|
60
|
+
|
61
|
+
ask("Which organization", :choices => orgs.sort_by(&:name),
|
62
|
+
:display => proc(&:name))
|
63
|
+
end
|
64
|
+
|
65
|
+
def ask_really(org)
|
66
|
+
ask("Really delete #{c(org.name, :name)}?", :default => false)
|
67
|
+
end
|
68
|
+
|
69
|
+
def ask_recursive
|
70
|
+
ask "Delete #{c("EVERYTHING", :bad)}?", :default => false
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "cf/cli/organization/base"
|
2
|
+
|
3
|
+
module CF::Organization
|
4
|
+
class Org < Base
|
5
|
+
desc "Show organization information"
|
6
|
+
group :organizations
|
7
|
+
input :organization, :desc => "Organization to show",
|
8
|
+
:aliases => %w{--org -o}, :argument => :optional,
|
9
|
+
:from_given => by_name(:organization),
|
10
|
+
:default => proc { client.current_organization }
|
11
|
+
input :full, :desc => "Show full information for spaces, domains, etc.",
|
12
|
+
:default => false
|
13
|
+
def org
|
14
|
+
org = input[:organization]
|
15
|
+
|
16
|
+
unless org
|
17
|
+
return if quiet?
|
18
|
+
fail "No current organization."
|
19
|
+
end
|
20
|
+
|
21
|
+
if quiet?
|
22
|
+
puts org.name
|
23
|
+
return
|
24
|
+
end
|
25
|
+
|
26
|
+
line "#{c(org.name, :name)}:"
|
27
|
+
|
28
|
+
indented do
|
29
|
+
line "domains: #{name_list(org.domains)}"
|
30
|
+
|
31
|
+
if input[:full]
|
32
|
+
line "spaces:"
|
33
|
+
|
34
|
+
spaced(org.spaces(:depth => 2)) do |s|
|
35
|
+
indented do
|
36
|
+
invoke :space, :space => s
|
37
|
+
end
|
38
|
+
end
|
39
|
+
else
|
40
|
+
line "spaces: #{name_list(org.spaces)}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|