org.infinispan.cli.commands.Counter Maven / Gradle / Ivy
package org.infinispan.cli.commands;
import org.aesh.command.Command;
import org.aesh.command.CommandDefinition;
import org.aesh.command.CommandException;
import org.aesh.command.CommandResult;
import org.aesh.command.option.Argument;
import org.aesh.command.option.Option;
import org.infinispan.cli.activators.ConnectionActivator;
import org.infinispan.cli.completers.CounterCompleter;
import org.infinispan.cli.impl.ContextAwareCommandInvocation;
import org.infinispan.cli.resources.ContainerResource;
import org.infinispan.cli.resources.CountersResource;
import org.kohsuke.MetaInfServices;
/**
* @author Tristan Tarrant <[email protected]>
* @since 10.0
**/
@MetaInfServices(Command.class)
@CommandDefinition(name = "counter", description = "Selects counters", activator = ConnectionActivator.class)
public class Counter extends CliCommand {
@Argument(description = "The name of the counter to select", completer = CounterCompleter.class, required = true)
String name;
@Option(shortName = 'h', hasValue = false, overrideRequired = true)
protected boolean help;
@Override
public boolean isHelp() {
return help;
}
@Override
public CommandResult exec(ContextAwareCommandInvocation invocation) throws CommandException {
return invocation.getContext().changeResource(ContainerResource.class, CountersResource.NAME, name);
}
}