org.infinispan.cli.commands.Disconnect Maven / Gradle / Ivy
package org.infinispan.cli.commands;
import org.aesh.command.Command;
import org.aesh.command.CommandDefinition;
import org.aesh.command.CommandResult;
import org.aesh.command.option.Option;
import org.infinispan.cli.activators.ConnectionActivator;
import org.infinispan.cli.impl.ContextAwareCommandInvocation;
import org.kohsuke.MetaInfServices;
/**
* @author Tristan Tarrant <[email protected]>
* @since 10.0
**/
@MetaInfServices(Command.class)
@CommandDefinition(name = "disconnect", description = "Disconnects from a remote server", activator = ConnectionActivator.class)
public class Disconnect extends CliCommand {
@Option(shortName = 'h', hasValue = false, overrideRequired = true)
protected boolean help;
@Override
public boolean isHelp() {
return help;
}
@Override
public CommandResult exec(ContextAwareCommandInvocation invocation) {
if (invocation.getContext().isConnected()) {
invocation.getContext().disconnect();
return CommandResult.SUCCESS;
} else {
invocation.getShell().writeln("Not connected");
return CommandResult.FAILURE;
}
}
}