Package org.jboss.as.cli

Examples of org.jboss.as.cli.CommandLineCompleter


        super("undeploy", true);

        l = new ArgumentWithoutValue(this, "-l");
        l.setExclusive(true);

        name = new ArgumentWithValue(this, new CommandLineCompleter() {
            @Override
            public int complete(CommandContext ctx, String buffer, int cursor, List<String> candidates) {

                int nextCharIndex = 0;
                while (nextCharIndex < buffer.length()) {
                    if (!Character.isWhitespace(buffer.charAt(nextCharIndex))) {
                        break;
                    }
                    ++nextCharIndex;
                }

                if(ctx.getModelControllerClient() != null) {
                    List<String> deployments = Util.getDeployments(ctx.getModelControllerClient());
                    if(deployments.isEmpty()) {
                        return -1;
                    }

                    String opBuffer = buffer.substring(nextCharIndex).trim();
                    if (opBuffer.isEmpty()) {
                        candidates.addAll(deployments);
                    } else {
                        for(String name : deployments) {
                            if(name.startsWith(opBuffer)) {
                                candidates.add(name);
                            }
                        }
                        Collections.sort(candidates);
                    }
                    return nextCharIndex;
                } else {
                    return -1;
                }

            }}, 0, "--name");
        name.addCantAppearAfter(l);

        allRelevantServerGroups = new ArgumentWithoutValue(this, "--all-relevant-server-groups") {
            @Override
            public boolean canAppearNext(CommandContext ctx) throws CommandFormatException {
                if(!ctx.isDomainMode()) {
                    return false;
                }
                return super.canAppearNext(ctx);
            }
        };
        allRelevantServerGroups.addRequiredPreceding(name);

        serverGroups = new ArgumentWithValue(this, new CommandLineCompleter() {
            @Override
            public int complete(CommandContext ctx, String buffer, int cursor, List<String> candidates) {

                if(buffer.isEmpty()) {
                    candidates.addAll(Util.getServerGroups(ctx.getModelControllerClient()));
View Full Code Here


            return -1;
        }

        int result = buffer.length();
        String chunk = null;
        CommandLineCompleter valueCompleter = null;
        if (firstCharIndex != result) {

            if(results.argValue != null) {
                if(results.argValue.isEmpty()) {
                    chunk = null;
                    result = results.valueStart;

                    if(results.argName != null) {
                        for(CommandArgument arg : allArgs) {
                            if(results.argName.equals(arg.getFullName())) {
                                valueCompleter = arg.getValueCompleter();
                                break;
                            }
                        }
                    } else {
                        for (CommandArgument arg : allArgs) {
                            try {
                                if (arg.getIndex() >= 0 && arg.canAppearNext(ctx)) {
                                    valueCompleter = arg.getValueCompleter();
                                    break;
                                }
                            } catch (CommandFormatException e) {
                                return -1;
                            }
                        }
                    }

                    if(valueCompleter == null) {
                        return -1;
                    }
                } else {
                    if(results.endIndex < buffer.length()) {
                        chunk = null;
                    } else {
                        chunk = results.argValue;
                        result = results.valueStart;

                        if(results.argName != null) {
                            for(CommandArgument arg : allArgs) {
                                if(results.argName.equals(arg.getFullName())) {
                                    valueCompleter = arg.getValueCompleter();
                                    break;
                                }
                            }
                        } else {
                            for (CommandArgument arg : allArgs) {
                                try {
                                    if (arg.getIndex() >= 0 && arg.canAppearNext(ctx)) {
                                        valueCompleter = arg.getValueCompleter();
                                        break;
                                    }
                                } catch (CommandFormatException e) {
                                    return -1;
                                }
                            }
                        }

                        if(valueCompleter == null) {
                            return -1;
                        }
                    }
                }
            } else {
                if(results.endIndex < buffer.length()) {
                    chunk = null;
                } else {
                    chunk = results.argName;
                    if (results.argName != null) {
                        result = results.nameStart;
                    }
                }
            }
        }

        if(valueCompleter != null) {
            int valueResult = valueCompleter.complete(ctx, chunk == null ? "" : chunk, cursor, candidates);
            if(valueResult < 0) {
                return valueResult;
            } else {
                return result + valueResult;
            }
        }

        for(CommandArgument arg : allArgs) {
            try {
                if(arg.canAppearNext(ctx)) {
                    if(arg.getIndex() >= 0) {
                        CommandLineCompleter valCompl = arg.getValueCompleter();
                        if(valCompl != null) {
                            valCompl.complete(ctx, chunk == null ? "" : chunk, cursor, candidates);
                        }
                    } else {
                        String argName = arg.getFullName();
                        if (chunk == null) {
                            if (arg.isValueRequired()) {
View Full Code Here

                }
                return super.canAppearNext(ctx);
            }
        };

        operation = new ArgumentWithValue(this, new CommandLineCompleter(){
            @Override
            public int complete(CommandContext ctx, String buffer, int cursor, List<String> candidates) {
                final StringBuilder buf = new StringBuilder();
                if(ctx.isDomainMode()) {
                    final String profileName = profile.getValue(ctx.getParsedArguments());
View Full Code Here

public class DeleteJmsTopicHandler extends BatchModeCommandHandler {

    public DeleteJmsTopicHandler() {
        super("delete-jms-topic", true,
                new SimpleTabCompleterWithDelegate(new String[]{"--help"/*, "name="*/},
                        new CommandLineCompleter() {
                    @Override
                    public int complete(CommandContext ctx, String buffer,
                            int cursor, List<String> candidates) {

                        int nextCharIndex = 0;
View Full Code Here

* @author Alexey Loubyansky
*/
public class BatchHandler extends CommandHandlerWithHelp {

    public BatchHandler() {
        super("batch", new SimpleTabCompleterWithDelegate(new String[]{"-l", "--help"}, new CommandLineCompleter(){
            @Override
            public int complete(CommandContext ctx, String buffer, int cursor, List<String> candidates) {

                BatchManager batchManager = ctx.getBatchManager();
                Set<String> names = batchManager.getHeldbackNames();
View Full Code Here

* @author Alexey Loubyansky
*/
public class BatchEditLineHandler extends CommandHandlerWithHelp {

    public BatchEditLineHandler() {
        super("batch-edit-line", new CommandLineCompleter() {
            @Override
            public int complete(CommandContext ctx, String buffer, int cursor, List<String> candidates) {

                final BatchManager batchManager = ctx.getBatchManager();
                if(!batchManager.isBatchActive()) {
View Full Code Here

public class DeleteJmsCFHandler extends BatchModeCommandHandler {

    public DeleteJmsCFHandler() {
        super("delete-jms-cf", true,
                new SimpleTabCompleterWithDelegate(new String[]{"--help"/*, "name="*/},
                        new CommandLineCompleter() {
                    @Override
                    public int complete(CommandContext ctx, String buffer,
                            int cursor, List<String> candidates) {

                        int nextCharIndex = 0;
View Full Code Here

*/
public class UndeployHandler extends BatchModeCommandHandler {

    public UndeployHandler() {
        super("undeploy", true, new SimpleTabCompleterWithDelegate(new String[]{"--help", "-l"},
                new CommandLineCompleter() {
                    @Override
                    public int complete(CommandContext ctx, String buffer,
                            int cursor, List<String> candidates) {

                        int nextCharIndex = 0;
View Full Code Here

public class DeleteJmsQueueHandler extends BatchModeCommandHandler {

    public DeleteJmsQueueHandler() {
        super("delete-jms-queue", true,
                new SimpleTabCompleterWithDelegate(new String[]{"--help"/*, "name="*/},
                        new CommandLineCompleter() {
                    @Override
                    public int complete(CommandContext ctx, String buffer,
                            int cursor, List<String> candidates) {

                        int nextCharIndex = 0;
View Full Code Here

            try {
                if (!parsedCmd.hasProperties()) {
                    for (CommandArgument arg : allArgs) {
                        if (arg.canAppearNext(ctx)) {
                            if (arg.getIndex() >= 0) {
                                final CommandLineCompleter valCompl = arg.getValueCompleter();
                                if (valCompl != null) {
                                    valCompl.complete(ctx, "", 0, candidates);
                                }
                            } else {
                                String argName = arg.getFullName();
                                if (arg.isValueRequired()) {
                                    argName += '=';
                                }
                                candidates.add(argName);
                            }
                        }
                    }
                    Collections.sort(candidates);
                    return buffer.length();
                }
            } catch (CommandFormatException e) {
                return -1;
            }

            int result = buffer.length();

            String chunk = null;
            CommandLineCompleter valueCompleter = null;
            if (!parsedCmd.endsOnPropertySeparator()) {
                final String argName = parsedCmd.getLastParsedPropertyName();
                final String argValue = parsedCmd.getLastParsedPropertyValue();
                if (argValue != null || parsedCmd.endsOnPropertyValueSeparator()) {
                    result = parsedCmd.getLastChunkIndex();
                    if (parsedCmd.endsOnPropertyValueSeparator()) {
                        ++result;// it enters on '='
                    }
                    chunk = argValue;
                    if (argName != null) {
                        valueCompleter = getValueCompleter(ctx, allArgs, argName);
                    } else {
                        valueCompleter = getValueCompleter(ctx, allArgs, parsedCmd.getOtherProperties().size() - 1);
                    }
                    if (valueCompleter == null) {
                        if (parsedCmd.endsOnSeparator()) {
                            return -1;
                        }
                        for (CommandArgument arg : allArgs) {
                            try {
                                if (arg.canAppearNext(ctx) && !arg.getFullName().equals(argName)) {
                                    return -1;
                                }
                            } catch (CommandFormatException e) {
                                break;
                            }
                        }
                        final CommandLineFormat format = parsedCmd.getFormat();
                        if(format != null && format.getPropertyListEnd() != null) {
                            candidates.add(format.getPropertyListEnd());
                        }
                        return buffer.length();
                    }
                } else {
                    chunk = argName;
                    result = parsedCmd.getLastChunkIndex();
                }
            } else {
                chunk = null;
            }

            if (valueCompleter != null) {
                int valueResult = valueCompleter.complete(ctx, chunk == null ? "" : chunk, 0, candidates);
                if (valueResult < 0) {
                    return valueResult;
                } else {
                    return result + valueResult;
                }
            }

            for (CommandArgument arg : allArgs) {
                try {
                    if (arg.canAppearNext(ctx)) {
                        if (arg.getIndex() >= 0) {
                            CommandLineCompleter valCompl = arg.getValueCompleter();
                            if (valCompl != null) {
                                final String value = chunk == null ? "" : chunk;
                                valCompl.complete(ctx, value, value.length(), candidates);
                            }
                        } else {
                            String argFullName = arg.getFullName();
                            if (chunk == null) {
                                if (arg.isValueRequired()) {
View Full Code Here

TOP

Related Classes of org.jboss.as.cli.CommandLineCompleter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.