Examples of Completer


Examples of jline.console.completer.Completer

        if (command.getName().equals(commandName)) {
          if (cursor == buffer.length() && buffer.endsWith(" ")) {
            printUsage(command);
            break;
          }
          Completer completer = this.commandCompleters.get(command.getName());
          if (completer != null) {
            completionIndex = completer.complete(buffer, cursor, candidates);
            break;
          }
        }
      }
    }
View Full Code Here

Examples of jline.console.completer.Completer

            args.remove(token);
          }
          completers.add(new StringsCompleter(token));
        }
        completers.add(new StringsCompleter(args));
        Completer completer = new ArgumentCompleter(completers);
        return completer.complete(buffer, cursor, candidates);
      } else if (CliConstants.HELP_ACTION.equals(action)) {
        // For help action, we need to display available commands as arguments
        return helpCommandCompleter.complete(buffer, cursor, candidates);
      }
    }
View Full Code Here

Examples of jline.console.completer.Completer

    public DelegatingCompleter(ClassFinder classFinder) throws IOException, ClassNotFoundException {
        ClojureCompletionWrapper wrapper = new ClojureCompletionWrapper();

        DefaultCompleter DEFAULT_COMPLETER = new DefaultCompleter(wrapper);
        JavaInvocationCompleter JAVA_COMPLETER = new JavaInvocationCompleter();
        Completer FQN_CLASS_FINDER = new FqnClassCompleter(classFinder);

        // java interop
        completers.put(pattern("\\(\\. "), JAVA_COMPLETER);

        // import
        Completer PACKAGE_NAME_COMPLETER = new PackageNameCompleter(classFinder);
        completers.put(pattern("\\(import \\["), PACKAGE_NAME_COMPLETER);
        completers.put(pattern("\\(import '\\("), PACKAGE_NAME_COMPLETER);
        completers.put(pattern("\\(import '"), FQN_CLASS_FINDER);
        completers.put(pattern("\\(import "), FQN_CLASS_FINDER);
View Full Code Here

Examples of org.apache.felix.karaf.shell.console.Completer

        if (argIndex < 0) {
            return -1;
        }

        final Completer comp;

        // if we are beyond the end of the completors, just use the last one
        if (argIndex >= completers.length) {
            comp = completers[completers.length - 1];
        } else {
            comp = completers[argIndex];
        }

        // ensure that all the previous completors are successful before
        // allowing this completor to pass (only if strict is true).
        for (int i = 0; getStrict() && (i < argIndex); i++) {
            Completer sub = completers[(i >= completers.length) ? (completers.length - 1) : i];
            String[] args = list.getArguments();
            String arg = ((args == null) || (i >= args.length)) ? "" : args[i];

            List<String> subCandidates = new LinkedList<String>();

            if (sub.complete(arg, arg.length(), subCandidates) == -1) {
                return -1;
            }

            if (subCandidates.size() == 0) {
                return -1;
View Full Code Here

Examples of org.apache.karaf.shell.api.console.Completer

        return null;
    }

    @Override
    public Completer getCompleter(final boolean scoped) {
        return new Completer() {
            @Override
            public int complete(Session session, CommandLine commandLine, List<String> candidates) {
                String[] args = commandLine.getArguments();
                int argIndex = commandLine.getCursorArgumentIndex();
                StringsCompleter completer = new StringsCompleter(Collections.singletonList(getName()));
View Full Code Here

Examples of org.apache.karaf.shell.console.Completer

                    }
                }
            });
        }
        session.put(".jline.history", reader.getHistory());
        Completer completer = createCompleter();
        if (completer != null) {
            reader.addCompleter(new CompleterAsCompletor(completer));
        }
        if (Boolean.getBoolean("jline.nobell")) {
            reader.setBellEnabled(false);
View Full Code Here

Examples of org.apache.karaf.shell.console.Completer

            }
        }

        session.put(".jline.reader", reader);
        session.put(".jline.history", reader.getHistory());
        Completer completer = createCompleter();
        if (completer != null) {
            reader.addCompleter(new CompleterAsCompletor(completer));
        }
        pipe = new Thread(new Pipe());
        pipe.setName("gogo shell pipe thread");
View Full Code Here

Examples of org.apache.karaf.shell.console.Completer

    } catch (Exception e) {
      LOGGER.error("Can not read history from file " + file + ". Using in memory history", e);
    }
        session.put(".jline.reader", reader);
        session.put(".jline.history", reader.getHistory());
        Completer completer = createCompleter();
        if (completer != null) {
            reader.addCompleter(new CompleterAsCompletor(completer));
        }
        pipe = new Thread(new Pipe());
        pipe.setName("gogo shell pipe thread");
View Full Code Here

Examples of org.apache.karaf.shell.console.Completer

                        }
                    }
                }
            }
            for (int i = 0, size = arguments.size(); i < size; i++) {
                Completer argCompleter = NullCompleter.INSTANCE;
                Method method = methods.get(i);
                if (method != null) {
                    // lets invoke the method
                    Action action = function.createNewAction();
                    try {
View Full Code Here

Examples of org.apache.karaf.shell.console.Completer

        CommandSession commandSession = CommandSessionHolder.getSession();
        if(commandSession != null) {
            commandSession.put(ARGUMENTS_LIST,list);
        }

        Completer comp = null;
        String[] args = list.getArguments();
        int index = 0;
        // First argument is command name
        if (index < argIndex) {
            // Verify command name
            if (!verifyCompleter(commandCompleter, args[index])) {
                return -1;
            }
            // Verify scope if
            // - the command name has no scope
            // - we have a session
            if (!args[index].contains(":") && commandSession != null) {
                Function f1 = unProxy((Function) commandSession.get("*:" + args[index]));
                Function f2 = unProxy(this.function);
                if (f1 != null && f1 != f2) {
                    return -1;
                }
            }
            index++;
        } else {
            comp = commandCompleter;
        }
        // Now, check options
        if (comp == null) {
            while (index < argIndex && args[index].startsWith("-")) {
                if (!verifyCompleter(optionsCompleter, args[index])) {
                    return -1;
                }
                Option option = options.get(args[index]);
                if (option == null) {
                    return -1;
                }
                Field field = fields.get(option);
                if (field != null && field.getType() != boolean.class && field.getType() != Boolean.class) {
                    if (++index == argIndex) {
                        comp = NullCompleter.INSTANCE;
                    }
                }
                index++;
            }
            if (comp == null && index >= argIndex && index < args.length && args[index].startsWith("-")) {
                comp = optionsCompleter;
            }
        }
        //Now check for if last Option has a completer
        int lastAgurmentIndex = argIndex - 1;
        if (lastAgurmentIndex >= 1) {
            Option lastOption = options.get(args[lastAgurmentIndex]);
            if (lastOption != null) {

                Field lastField = fields.get(lastOption);
                if (lastField != null && lastField.getType() != boolean.class && lastField.getType() != Boolean.class) {
                    Option option = lastField.getAnnotation(Option.class);
                    if (option != null) {
                        Completer optionValueCompleter = null;
                        String name = option.name();
                        if (optionalCompleters != null && name != null) {
                            optionValueCompleter = optionalCompleters.get(name);
                            if (optionValueCompleter == null) {
                                String[] aliases = option.aliases();
                                if (aliases.length > 0) {
                                    for (int i = 0; i < aliases.length && optionValueCompleter == null; i++) {
                                        optionValueCompleter = optionalCompleters.get(option.aliases()[i]);
                                    }
                                }
                            }
                        }
                        if(optionValueCompleter != null) {
                            comp = optionValueCompleter;
                        }
                    }
                }
            }
        }

        // Check arguments
        if (comp == null) {
            int indexArg = 0;
            while (index < argIndex) {
                Completer sub = argsCompleters.get(indexArg >= argsCompleters.size() ? argsCompleters.size() - 1 : indexArg);
                if (!verifyCompleter(sub, args[index])) {
                    return -1;
                }
                index++;
                indexArg++;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.