Skip to content

Added several new commands #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions src/main/resources/crash/commands/vertx/vertx.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ public class vertx extends VertxCommand {
context.provide(["property":"main", "value":deployment.main]);
}

@Command
@Usage("stop vertx")
public String stop() {
System.exit(0)
}

@Command
@Usage("undeploy a deployment")
public void undeploy(
Expand All @@ -149,6 +155,146 @@ public class vertx extends VertxCommand {
manager.undeploy(id, null);
}

@Command
@Usage("Undeploy all deployments containing the given module id (owner~name~version)")
public TreeElement undeployByModId(
@Usage("The module id")
@Argument(name = "id")
@Required String id) {

if(id == "null") return new TreeElement("Cannot undeploy null module id")

String result = ""
for(deployment in deployments)
{
if(deployment.value.modID.toString().equals(id))
{
undeploy(deployment.value.name)
result += "Undeployed " + deployment.value.name +"\n"
}
}
if(result.equals("")) return new TreeElement("No existing deployments contain " + id)
return result;
}

@Command
@Usage("Undeploy and uninstall all deployments containing the given module id (owner~name~version)")
public TreeElement undeployUninstallByModId(
@Usage("The module id")
@Argument(name = "id")
@Required String id) {

if(id == "null") return new TreeElement("Cannot undeploy null module id")

String result = ""
for(deployment in deployments)
{
if(deployment.value.modID.toString().equals(id))
{
undeploy(deployment.value.name)
result += "Undeployed " + deployment.value.name +"\n"
manager.uninstallModule(deployment.value.modID.toString(),null)
result += "Uninstalled " + deployment.value.modID.toString() + "\n"
}
}
if(result.equals("")) return new TreeElement("No existing deployments contain " + id)
return result;
}

@Command
@Usage("Undeploy all deployments containing the given module owner and name")
public TreeElement undeployByModName(
@Usage("The module Owner~Name, not including version number")
@Argument(name = "ownerName")
@Required String ownerName) {

if(ownerName == "null") return new TreeElement("Cannot undeploy null module id")

String result = ""
for(deployment in deployments)
{
if(!(deployment.value.modID == null))
{
def combinedName = deployment.value.modID.owner + "~" + deployment.value.modID.name
if(combinedName.equals(ownerName))
{
undeploy(deployment.value.name) // deployment name (ex: deployment-f4e43882-131d-465a-a12b-051a5f54e851)
result += "Undeployed " + deployment.value.name +"\n"
}
}
}

if(result.equals("")) return new TreeElement("No existing deployments contain " + ownerName)
return new TreeElement(result)
}

@Command
@Usage("Undeploy and uninstall all deployments containing the given module owner and name")
public TreeElement undeployUninstallByModName(
@Usage("The module Owner~Name, not including version number")
@Argument(name = "ownerName")
@Required String ownerName) {

if(ownerName == "null") return new TreeElement("Cannot undeploy null module id")

String result = ""
for(deployment in deployments)
{
if(!(deployment.value.modID == null))
{
def combinedName = deployment.value.modID.owner + "~" + deployment.value.modID.name
if(combinedName.equals(ownerName))
{
undeploy(deployment.value.name) // deployment name (ex: deployment-f4e43882-131d-465a-a12b-051a5f54e851)
result += "Undeployed " + deployment.value.name +"\n"
manager.uninstallModule(deployment.value.modID.toString(),null)
result += "Uninstalled " + deployment.value.modID.toString() + "\n"
}
}
}

if(result.equals("")) return new TreeElement("No existing deployments contain " + ownerName)
return new TreeElement(result)
}

@Command
@Usage("Undeploy all deployments")
public TreeElement undeployAll(){

String result = ""
for(deployment in deployments)
{
if(!(deployment.value.modID == null) && !deployment.value.modID.name.equals("vertx.shell"))
{
undeploy(deployment.value.name) // deployment name (ex: deployment-f4e43882-131d-465a-a12b-051a5f54e851)
result += "Undeployed " + deployment.value.name + "\n"
}
}

if(result.equals("")) return new TreeElement("No existing deployments")
return new TreeElement(result)
}

@Command
@Usage("Undeploy and uninstall all deployments")
public TreeElement undeployUninstallAll(){

String result = ""
for(deployment in deployments)
{
if(!(deployment.value.modID == null) && !deployment.value.modID.name.equals("vertx.shell"))
{
undeploy(deployment.value.name) // deployment name (ex: deployment-f4e43882-131d-465a-a12b-051a5f54e851)
result += "Undeployed " + deployment.value.name + "\n"
manager.uninstallModule(deployment.value.modID.toString(),null)
result += "Uninstalled " + deployment.value.modID.toString() + "\n"
}
}

if(result.equals("")) return new TreeElement("No existing deployments")
return new TreeElement(result)
}

@Command
@Usage("display vert.x config")
public void config() {
Expand Down