vmc 0.4.0.beta.80 → 0.4.0.beta.81
Sign up to get free protection for your applications and to get access to all the features.
- data/vmc-ng/lib/vmc/cli.rb +9 -1
- data/vmc-ng/lib/vmc/cli/domain.rb +1 -1
- data/vmc-ng/lib/vmc/cli/organization.rb +93 -1
- data/vmc-ng/lib/vmc/cli/space.rb +14 -2
- data/vmc-ng/lib/vmc/cli/start.rb +9 -1
- data/vmc-ng/lib/vmc/version.rb +1 -1
- metadata +4 -4
data/vmc-ng/lib/vmc/cli.rb
CHANGED
@@ -66,11 +66,13 @@ module VMC
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
69
|
+
def check_target
|
70
70
|
unless File.exists? target_file
|
71
71
|
fail "Please select a target with 'vmc target'."
|
72
72
|
end
|
73
|
+
end
|
73
74
|
|
75
|
+
def check_logged_in
|
74
76
|
unless client.logged_in?
|
75
77
|
if force?
|
76
78
|
fail "Please log in with 'vmc login'."
|
@@ -81,6 +83,11 @@ module VMC
|
|
81
83
|
invalidate_client
|
82
84
|
end
|
83
85
|
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def precondition
|
89
|
+
check_target
|
90
|
+
check_logged_in
|
84
91
|
|
85
92
|
return unless v2?
|
86
93
|
|
@@ -97,6 +104,7 @@ module VMC
|
|
97
104
|
if input[:help]
|
98
105
|
invoke :help, :command => cmd.name.to_s
|
99
106
|
else
|
107
|
+
@command = cmd
|
100
108
|
precondition
|
101
109
|
super
|
102
110
|
end
|
@@ -3,7 +3,9 @@ require "vmc/cli"
|
|
3
3
|
module VMC
|
4
4
|
class Organization < CLI
|
5
5
|
def precondition
|
6
|
-
|
6
|
+
check_target
|
7
|
+
check_logged_in
|
8
|
+
|
7
9
|
fail "This command is v2-only." unless v2?
|
8
10
|
end
|
9
11
|
|
@@ -26,6 +28,11 @@ module VMC
|
|
26
28
|
def org
|
27
29
|
org = input[:organization]
|
28
30
|
|
31
|
+
unless org
|
32
|
+
return if quiet?
|
33
|
+
fail "No current organization."
|
34
|
+
end
|
35
|
+
|
29
36
|
if quiet?
|
30
37
|
puts org.name
|
31
38
|
return
|
@@ -80,5 +87,90 @@ module VMC
|
|
80
87
|
end
|
81
88
|
end
|
82
89
|
end
|
90
|
+
|
91
|
+
|
92
|
+
desc "Create an organization"
|
93
|
+
group :organizations
|
94
|
+
input(:name, :argument => :optional, :desc => "Organization name") {
|
95
|
+
ask("Name")
|
96
|
+
}
|
97
|
+
input :target, :alias => "-t", :type => :boolean,
|
98
|
+
:desc => "Switch to the organization after creation"
|
99
|
+
input :add_self, :type => :boolean, :default => true,
|
100
|
+
:desc => "Add yourself to the organization"
|
101
|
+
def create_org
|
102
|
+
org = client.organization
|
103
|
+
org.name = input[:name]
|
104
|
+
org.users = [client.current_user] if input[:add_self]
|
105
|
+
|
106
|
+
with_progress("Creating organization #{c(org.name, :name)}") do
|
107
|
+
org.create!
|
108
|
+
end
|
109
|
+
|
110
|
+
if input[:target]
|
111
|
+
invoke :target, :organization => org
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
desc "Delete an organization"
|
117
|
+
group :organizations
|
118
|
+
input(:organization, :aliases => ["--org", "-o"],
|
119
|
+
:argument => :optional,
|
120
|
+
:from_given => by_name("organization"),
|
121
|
+
:desc => "Organization to delete") { |orgs|
|
122
|
+
ask "Which organization?", :choices => orgs,
|
123
|
+
:display => proc(&:name)
|
124
|
+
}
|
125
|
+
input(:really, :type => :boolean, :forget => true,
|
126
|
+
:default => proc { force? || interact }) { |org|
|
127
|
+
ask("Really delete #{c(org.name, :name)}?", :default => false)
|
128
|
+
}
|
129
|
+
input(:recursive, :alias => "-r", :type => :boolean, :forget => true) {
|
130
|
+
ask "Delete #{c("EVERYTHING", :bad)}?", :default => false
|
131
|
+
}
|
132
|
+
input :warn, :type => :boolean, :default => true,
|
133
|
+
:desc => "Show warning if it was the last org"
|
134
|
+
def delete_org
|
135
|
+
orgs = client.organizations
|
136
|
+
fail "No organizations." if orgs.empty?
|
137
|
+
|
138
|
+
org = input[:organization, orgs]
|
139
|
+
return unless input[:really, org]
|
140
|
+
|
141
|
+
spaces = org.spaces
|
142
|
+
unless spaces.empty?
|
143
|
+
unless force?
|
144
|
+
line "This organization is not empty!"
|
145
|
+
line
|
146
|
+
line "spaces: #{name_list(spaces)}"
|
147
|
+
line
|
148
|
+
|
149
|
+
return unless input[:recursive]
|
150
|
+
end
|
151
|
+
|
152
|
+
spaces.each do |s|
|
153
|
+
invoke :delete_space, :space => s, :really => true,
|
154
|
+
:recursive => true, :warn => false
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
is_current = org == client.current_organization
|
159
|
+
|
160
|
+
with_progress("Deleting organization #{c(org.name, :name)}") do
|
161
|
+
org.delete!
|
162
|
+
end
|
163
|
+
|
164
|
+
if orgs.size == 1
|
165
|
+
return unless input[:warn]
|
166
|
+
|
167
|
+
line
|
168
|
+
line c("There are no longer any organizations.", :warning)
|
169
|
+
line "You may want to create one with #{c("create-org", :good)}."
|
170
|
+
elsif is_current
|
171
|
+
invalidate_target
|
172
|
+
invoke :target
|
173
|
+
end
|
174
|
+
end
|
83
175
|
end
|
84
176
|
end
|
data/vmc-ng/lib/vmc/cli/space.rb
CHANGED
@@ -3,7 +3,9 @@ require "vmc/cli"
|
|
3
3
|
module VMC
|
4
4
|
class Space < CLI
|
5
5
|
def precondition
|
6
|
-
|
6
|
+
check_target
|
7
|
+
check_logged_in
|
8
|
+
|
7
9
|
fail "This command is v2-only." unless v2?
|
8
10
|
end
|
9
11
|
|
@@ -37,6 +39,11 @@ module VMC
|
|
37
39
|
org = input[:organization]
|
38
40
|
space = input[:space, org]
|
39
41
|
|
42
|
+
unless space
|
43
|
+
return if quiet?
|
44
|
+
fail "No current space."
|
45
|
+
end
|
46
|
+
|
40
47
|
if quiet?
|
41
48
|
puts space.name
|
42
49
|
return
|
@@ -122,7 +129,8 @@ module VMC
|
|
122
129
|
:from_given => by_name("organization"),
|
123
130
|
:default => proc { client.current_organization },
|
124
131
|
:desc => "Parent organization"
|
125
|
-
input :target, :alias => "-t", :type => :boolean
|
132
|
+
input :target, :alias => "-t", :type => :boolean,
|
133
|
+
:desc => "Switch to the space after creation"
|
126
134
|
input :manager, :type => :boolean, :default => true,
|
127
135
|
:desc => "Add current user as manager"
|
128
136
|
input :developer, :type => :boolean, :default => true,
|
@@ -196,6 +204,8 @@ module VMC
|
|
196
204
|
input(:recursive, :alias => "-r", :type => :boolean, :forget => true) {
|
197
205
|
ask "Delete #{c("EVERYTHING", :bad)}?", :default => false
|
198
206
|
}
|
207
|
+
input :warn, :type => :boolean, :default => true,
|
208
|
+
:desc => "Show warning if it was the last space"
|
199
209
|
def delete_space
|
200
210
|
org = input[:organization]
|
201
211
|
space = input[:space, org]
|
@@ -233,6 +243,8 @@ module VMC
|
|
233
243
|
org.invalidate!
|
234
244
|
|
235
245
|
if org.spaces.empty?
|
246
|
+
return unless input[:warn]
|
247
|
+
|
236
248
|
line
|
237
249
|
line c("There are no longer any spaces in #{b(org.name)}.", :warning)
|
238
250
|
line "You may want to create one with #{c("create-space", :good)}."
|
data/vmc-ng/lib/vmc/cli/start.rb
CHANGED
@@ -404,7 +404,15 @@ module VMC
|
|
404
404
|
if changed_org || input.given?(:space) || !space_valid?(info[:space])
|
405
405
|
spaces = org.spaces
|
406
406
|
|
407
|
-
|
407
|
+
if spaces.empty?
|
408
|
+
if changed_org
|
409
|
+
line c("There are no spaces in #{b(org.name)}.", :warning)
|
410
|
+
line "You may want to create one with #{c("create-space", :good)}."
|
411
|
+
return
|
412
|
+
else
|
413
|
+
fail "No spaces!"
|
414
|
+
end
|
415
|
+
end
|
408
416
|
|
409
417
|
if spaces.size == 1 && !input.given?(:space)
|
410
418
|
space = spaces.first
|
data/vmc-ng/lib/vmc/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: -2781116170
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 0.4.0.beta.
|
11
|
+
- 81
|
12
|
+
version: 0.4.0.beta.81
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- VMware
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-11-
|
20
|
+
date: 2012-11-07 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: json_pure
|