Search in sources :

Example 1 with SimpleTabCompleter

use of org.jboss.as.cli.handlers.SimpleTabCompleter in project wildfly-core by wildfly.

the class EmbedHostControllerHandler method create.

static EmbedHostControllerHandler create(final AtomicReference<EmbeddedProcessLaunch> hostControllerReference, final CommandContext ctx, final boolean modular) {
    EmbedHostControllerHandler result = new EmbedHostControllerHandler(hostControllerReference);
    final FilenameTabCompleter pathCompleter = FilenameTabCompleter.newCompleter(ctx);
    if (!modular) {
        result.jbossHome = new FileSystemPathArgument(result, pathCompleter, "--jboss-home");
    }
    result.stdOutHandling = new ArgumentWithValue(result, new SimpleTabCompleter(new String[] { ECHO, DISCARD_STDOUT }), "--std-out");
    result.domainConfig = new ArgumentWithValue(result, DOMAIN_CONFIG);
    result.hostConfig = new ArgumentWithValue(result, HOST_CONFIG);
    result.dashC = new ArgumentWithValue(result, "-c");
    result.dashC.addCantAppearAfter(result.domainConfig);
    result.domainConfig.addCantAppearAfter(result.dashC);
    result.timeout = new ArgumentWithValue(result, "--timeout");
    result.emptyDomainConfig = new ArgumentWithoutValue(result, EMPTY_DOMAIN_CONFIG);
    result.removeExistingDomainConfig = new ArgumentWithoutValue(result, REMOVE_EXISTING_DOMAIN_CONFIG);
    result.emptyHostConfig = new ArgumentWithoutValue(result, EMPTY_HOST_CONFIG);
    result.removeExistingHostConfig = new ArgumentWithoutValue(result, REMOVE_EXISTING_HOST_CONFIG);
    return result;
}
Also used : SimpleTabCompleter(org.jboss.as.cli.handlers.SimpleTabCompleter) FileSystemPathArgument(org.jboss.as.cli.impl.FileSystemPathArgument) ArgumentWithValue(org.jboss.as.cli.impl.ArgumentWithValue) FilenameTabCompleter(org.jboss.as.cli.handlers.FilenameTabCompleter) ArgumentWithoutValue(org.jboss.as.cli.impl.ArgumentWithoutValue)

Example 2 with SimpleTabCompleter

use of org.jboss.as.cli.handlers.SimpleTabCompleter in project wildfly-core by wildfly.

the class DefaultOperationCandidatesProvider method getAllowedCompleter.

private static CommandLineCompleter getAllowedCompleter(final Property prop) {
    final ModelNode allowedNode = prop.getValue().get(Util.ALLOWED);
    if (allowedNode.isDefined()) {
        final List<ModelNode> nodeList = allowedNode.asList();
        final String[] values = new String[nodeList.size()];
        for (int i = 0; i < values.length; ++i) {
            values[i] = nodeList.get(i).asString();
        }
        return new SimpleTabCompleter(values);
    }
    return null;
}
Also used : SimpleTabCompleter(org.jboss.as.cli.handlers.SimpleTabCompleter) ModelNode(org.jboss.dmr.ModelNode)

Example 3 with SimpleTabCompleter

use of org.jboss.as.cli.handlers.SimpleTabCompleter in project wildfly-core by wildfly.

the class MockOperationCandidatesProvider method getProperties.

@Override
public List<CommandArgument> getProperties(CommandContext ctx, String operationName, OperationRequestAddress address) {
    MockOperation operation = root.getOperation(operationName);
    if (operation == null) {
        return Collections.emptyList();
    }
    final List<MockOperationProperty> properties = operation.getProperties();
    final List<CommandArgument> result = new ArrayList<CommandArgument>(properties.size());
    for (final MockOperationProperty property : properties) {
        String name = property.getName();
        result.add(new CommandArgument() {

            @Override
            public String getFullName() {
                return name;
            }

            @Override
            public String getShortName() {
                return null;
            }

            @Override
            public int getIndex() {
                return -1;
            }

            @Override
            public boolean isPresent(ParsedCommandLine args) throws CommandFormatException {
                return args.hasProperty(name);
            }

            @Override
            public boolean canAppearNext(CommandContext ctx) throws CommandFormatException {
                ParsedCommandLine args = ctx.getParsedCommandLine();
                if (isPresent(args)) {
                    return !isValueComplete(args);
                }
                return true;
            }

            @Override
            public String getValue(ParsedCommandLine args) throws CommandFormatException {
                return args.getPropertyValue(name);
            }

            @Override
            public String getValue(ParsedCommandLine args, boolean required) throws CommandFormatException {
                if (!isPresent(args)) {
                    throw new CommandFormatException("Property '" + name + "' is missing required value.");
                }
                return args.getPropertyValue(name);
            }

            @Override
            public boolean isValueComplete(ParsedCommandLine args) throws CommandFormatException {
                if (!isPresent(args)) {
                    return false;
                }
                if (name.equals(args.getLastParsedPropertyName()) && !args.isLastPropertyNegated()) {
                    return false;
                }
                return true;
            }

            @Override
            public boolean isValueRequired() {
                return property.isValueRequired();
            }

            @Override
            public CommandLineCompleter getValueCompleter() {
                return property.getPossibleValues() != null ? new SimpleTabCompleter(property.getPossibleValues()) : null;
            }
        });
    }
    return result;
}
Also used : SimpleTabCompleter(org.jboss.as.cli.handlers.SimpleTabCompleter) CommandContext(org.jboss.as.cli.CommandContext) CommandArgument(org.jboss.as.cli.CommandArgument) ArrayList(java.util.ArrayList) CommandLineCompleter(org.jboss.as.cli.CommandLineCompleter) CommandFormatException(org.jboss.as.cli.CommandFormatException) ParsedCommandLine(org.jboss.as.cli.operation.ParsedCommandLine)

Example 4 with SimpleTabCompleter

use of org.jboss.as.cli.handlers.SimpleTabCompleter in project wildfly-core by wildfly.

the class EmbedServerHandler method create.

static EmbedServerHandler create(final AtomicReference<EmbeddedProcessLaunch> serverReference, CommandContext ctx, boolean modular) {
    EmbedServerHandler result = new EmbedServerHandler(serverReference);
    final FilenameTabCompleter pathCompleter = FilenameTabCompleter.newCompleter(ctx);
    if (!modular) {
        result.jbossHome = new FileSystemPathArgument(result, pathCompleter, "--jboss-home");
    }
    result.stdOutHandling = new ArgumentWithValue(result, new SimpleTabCompleter(new String[] { ECHO, DISCARD_STDOUT }), "--std-out");
    result.serverConfig = new ArgumentWithValue(result, "--server-config");
    result.dashC = new ArgumentWithValue(result, "-c");
    result.dashC.addCantAppearAfter(result.serverConfig);
    result.serverConfig.addCantAppearAfter(result.dashC);
    result.adminOnly = new ArgumentWithValue(result, SimpleTabCompleter.BOOLEAN, "--admin-only");
    result.emptyConfig = new ArgumentWithoutValue(result, "--empty-config");
    result.removeExisting = new ArgumentWithoutValue(result, "--remove-existing");
    result.removeExisting.addRequiredPreceding(result.emptyConfig);
    result.timeout = new ArgumentWithValue(result, "--timeout");
    return result;
}
Also used : SimpleTabCompleter(org.jboss.as.cli.handlers.SimpleTabCompleter) FileSystemPathArgument(org.jboss.as.cli.impl.FileSystemPathArgument) ArgumentWithValue(org.jboss.as.cli.impl.ArgumentWithValue) FilenameTabCompleter(org.jboss.as.cli.handlers.FilenameTabCompleter) ArgumentWithoutValue(org.jboss.as.cli.impl.ArgumentWithoutValue)

Aggregations

SimpleTabCompleter (org.jboss.as.cli.handlers.SimpleTabCompleter)4 FilenameTabCompleter (org.jboss.as.cli.handlers.FilenameTabCompleter)2 ArgumentWithValue (org.jboss.as.cli.impl.ArgumentWithValue)2 ArgumentWithoutValue (org.jboss.as.cli.impl.ArgumentWithoutValue)2 FileSystemPathArgument (org.jboss.as.cli.impl.FileSystemPathArgument)2 ArrayList (java.util.ArrayList)1 CommandArgument (org.jboss.as.cli.CommandArgument)1 CommandContext (org.jboss.as.cli.CommandContext)1 CommandFormatException (org.jboss.as.cli.CommandFormatException)1 CommandLineCompleter (org.jboss.as.cli.CommandLineCompleter)1 ParsedCommandLine (org.jboss.as.cli.operation.ParsedCommandLine)1 ModelNode (org.jboss.dmr.ModelNode)1