Skip to content

Commit d0c2944

Browse files
author
Zoooook
committed
Added several new commands, notably stop, undeployAll, and undeployUninstallAll
1 parent 96e74c3 commit d0c2944

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

src/main/resources/crash/commands/vertx/vertx.groovy

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ public class vertx extends VertxCommand {
140140
context.provide(["property":"main", "value":deployment.main]);
141141
}
142142

143+
@Command
144+
@Usage("stop vertx")
145+
public String stop() {
146+
System.exit(0)
147+
}
148+
143149
@Command
144150
@Usage("undeploy a deployment")
145151
public void undeploy(
@@ -149,6 +155,146 @@ public class vertx extends VertxCommand {
149155
manager.undeploy(id, null);
150156
}
151157

158+
@Command
159+
@Usage("Undeploy all deployments containing the given module id (owner~name~version)")
160+
public TreeElement undeployByModId(
161+
@Usage("The module id")
162+
@Argument(name = "id")
163+
@Required String id) {
164+
165+
if(id == "null") return new TreeElement("Cannot undeploy null module id")
166+
167+
String result = ""
168+
for(deployment in deployments)
169+
{
170+
if(deployment.value.modID.toString().equals(id))
171+
{
172+
undeploy(deployment.value.name)
173+
result += "Undeployed " + deployment.value.name +"\n"
174+
}
175+
}
176+
if(result.equals("")) return new TreeElement("No existing deployments contain " + id)
177+
return result;
178+
}
179+
180+
@Command
181+
@Usage("Undeploy and uninstall all deployments containing the given module id (owner~name~version)")
182+
public TreeElement undeployUninstallByModId(
183+
@Usage("The module id")
184+
@Argument(name = "id")
185+
@Required String id) {
186+
187+
if(id == "null") return new TreeElement("Cannot undeploy null module id")
188+
189+
String result = ""
190+
for(deployment in deployments)
191+
{
192+
if(deployment.value.modID.toString().equals(id))
193+
{
194+
undeploy(deployment.value.name)
195+
result += "Undeployed " + deployment.value.name +"\n"
196+
manager.uninstallModule(deployment.value.modID.toString(),null)
197+
result += "Uninstalled " + deployment.value.modID.toString() + "\n"
198+
}
199+
}
200+
if(result.equals("")) return new TreeElement("No existing deployments contain " + id)
201+
return result;
202+
}
203+
204+
@Command
205+
@Usage("Undeploy all deployments containing the given module owner and name")
206+
public TreeElement undeployByModName(
207+
@Usage("The module Owner~Name, not including version number")
208+
@Argument(name = "ownerName")
209+
@Required String ownerName) {
210+
211+
if(ownerName == "null") return new TreeElement("Cannot undeploy null module id")
212+
213+
String result = ""
214+
for(deployment in deployments)
215+
{
216+
if(!(deployment.value.modID == null))
217+
{
218+
def combinedName = deployment.value.modID.owner + "~" + deployment.value.modID.name
219+
if(combinedName.equals(ownerName))
220+
{
221+
undeploy(deployment.value.name) // deployment name (ex: deployment-f4e43882-131d-465a-a12b-051a5f54e851)
222+
result += "Undeployed " + deployment.value.name +"\n"
223+
}
224+
}
225+
}
226+
227+
if(result.equals("")) return new TreeElement("No existing deployments contain " + ownerName)
228+
return new TreeElement(result)
229+
}
230+
231+
@Command
232+
@Usage("Undeploy and uninstall all deployments containing the given module owner and name")
233+
public TreeElement undeployUninstallByModName(
234+
@Usage("The module Owner~Name, not including version number")
235+
@Argument(name = "ownerName")
236+
@Required String ownerName) {
237+
238+
if(ownerName == "null") return new TreeElement("Cannot undeploy null module id")
239+
240+
String result = ""
241+
for(deployment in deployments)
242+
{
243+
if(!(deployment.value.modID == null))
244+
{
245+
def combinedName = deployment.value.modID.owner + "~" + deployment.value.modID.name
246+
if(combinedName.equals(ownerName))
247+
{
248+
undeploy(deployment.value.name) // deployment name (ex: deployment-f4e43882-131d-465a-a12b-051a5f54e851)
249+
result += "Undeployed " + deployment.value.name +"\n"
250+
manager.uninstallModule(deployment.value.modID.toString(),null)
251+
result += "Uninstalled " + deployment.value.modID.toString() + "\n"
252+
}
253+
}
254+
}
255+
256+
if(result.equals("")) return new TreeElement("No existing deployments contain " + ownerName)
257+
return new TreeElement(result)
258+
}
259+
260+
@Command
261+
@Usage("Undeploy all deployments")
262+
public TreeElement undeployAll(){
263+
264+
String result = ""
265+
for(deployment in deployments)
266+
{
267+
if(!(deployment.value.modID == null) && !deployment.value.modID.name.equals("vertx.shell"))
268+
{
269+
undeploy(deployment.value.name) // deployment name (ex: deployment-f4e43882-131d-465a-a12b-051a5f54e851)
270+
result += "Undeployed " + deployment.value.name + "\n"
271+
}
272+
}
273+
274+
if(result.equals("")) return new TreeElement("No existing deployments")
275+
return new TreeElement(result)
276+
}
277+
278+
@Command
279+
@Usage("Undeploy and uninstall all deployments")
280+
public TreeElement undeployUninstallAll(){
281+
282+
String result = ""
283+
for(deployment in deployments)
284+
{
285+
if(!(deployment.value.modID == null) && !deployment.value.modID.name.equals("vertx.shell"))
286+
{
287+
undeploy(deployment.value.name) // deployment name (ex: deployment-f4e43882-131d-465a-a12b-051a5f54e851)
288+
result += "Undeployed " + deployment.value.name + "\n"
289+
manager.uninstallModule(deployment.value.modID.toString(),null)
290+
result += "Uninstalled " + deployment.value.modID.toString() + "\n"
291+
}
292+
}
293+
294+
if(result.equals("")) return new TreeElement("No existing deployments")
295+
return new TreeElement(result)
296+
}
297+
152298
@Command
153299
@Usage("display vert.x config")
154300
public void config() {

0 commit comments

Comments
 (0)