karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject karaf git commit: [KARAF-4963] "Old" shell commands doesn't work anymore
Date Mon, 30 Jan 2017 08:42:46 GMT
Repository: karaf
Updated Branches:
  refs/heads/master 833230987 -> a79f02115


[KARAF-4963] "Old" shell commands doesn't work anymore

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/a79f0211
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/a79f0211
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/a79f0211

Branch: refs/heads/master
Commit: a79f02115dd1e936ef3f2e6e99af9e554d17fe50
Parents: 8332309
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Mon Jan 30 09:42:28 2017 +0100
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Mon Jan 30 09:42:42 2017 +0100

----------------------------------------------------------------------
 shell/console/pom.xml                           |  6 +-
 .../java/jline/console/completer/Completer.java | 38 +++++++++++
 .../console/completer/StringsCompleter.java     | 66 ++++++++++++++++++++
 .../main/java/jline/internal/Preconditions.java | 27 ++++++++
 4 files changed, 135 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/a79f0211/shell/console/pom.xml
----------------------------------------------------------------------
diff --git a/shell/console/pom.xml b/shell/console/pom.xml
index 0fc579b..03cb24e 100644
--- a/shell/console/pom.xml
+++ b/shell/console/pom.xml
@@ -178,7 +178,8 @@
                             org.apache.felix.gogo.api;version=0.17.0;status=provisional;-noimport:=true,
                             org.apache.felix.gogo.commands.*;version=0.17.0;-noimport:=true,
                             org.apache.felix.service.command;version=0.17.0;status=provisional;-noimport:=true,
-                            org.apache.felix.service.threadio;version=0.17.0;status=provisional;-noimport:=true
+                            org.apache.felix.service.threadio;version=0.17.0;status=provisional;-noimport:=true;
+                            jline.console.completer;version=2.14;-noimport:=true
                         </Export-Package>
                         <Private-Package>
                         	org.apache.karaf.shell.commands.ansi,
@@ -186,7 +187,8 @@
                         	org.apache.karaf.shell.console.impl*,
                             org.apache.karaf.shell.security.impl*,
                             org.apache.karaf.shell.inject.impl*,
-                            org.apache.karaf.util.jaas
+                            org.apache.karaf.util.jaas,
+                            jline.internal
                         </Private-Package>
                         <Main-Class>
                             org.apache.karaf.shell.console.impl.Main

http://git-wip-us.apache.org/repos/asf/karaf/blob/a79f0211/shell/console/src/main/java/jline/console/completer/Completer.java
----------------------------------------------------------------------
diff --git a/shell/console/src/main/java/jline/console/completer/Completer.java b/shell/console/src/main/java/jline/console/completer/Completer.java
new file mode 100644
index 0000000..17e72a6
--- /dev/null
+++ b/shell/console/src/main/java/jline/console/completer/Completer.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2002-2016, the original author or authors.
+ *
+ * This software is distributable under the BSD license. See the terms of the
+ * BSD license in the documentation provided with this software.
+ *
+ * http://www.opensource.org/licenses/bsd-license.php
+ */
+package jline.console.completer;
+
+import java.util.List;
+
+/**
+ * A completer is the mechanism by which tab-completion candidates will be resolved.
+ *
+ * @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
+ * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
+ * @since 2.3
+ */
+public interface Completer
+{
+    //
+    // FIXME: Check if we can use CharSequece for buffer?
+    //
+
+    /**
+     * Populates <i>candidates</i> with a list of possible completions for the
<i>buffer</i>.
+     *
+     * The <i>candidates</i> list will not be sorted before being displayed to
the user: thus, the
+     * complete method should sort the {@link List} before returning.
+     *
+     * @param buffer        The buffer
+     * @param cursor        The current position of the cursor in the <i>buffer</i>
+     * @param candidates    The {@link List} of candidates to populate
+     * @return              The index of the <i>buffer</i> for which the completion
will be relative
+     */
+    int complete(String buffer, int cursor, List<CharSequence> candidates);
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/a79f0211/shell/console/src/main/java/jline/console/completer/StringsCompleter.java
----------------------------------------------------------------------
diff --git a/shell/console/src/main/java/jline/console/completer/StringsCompleter.java b/shell/console/src/main/java/jline/console/completer/StringsCompleter.java
new file mode 100644
index 0000000..7161f1d
--- /dev/null
+++ b/shell/console/src/main/java/jline/console/completer/StringsCompleter.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2002-2016, the original author or authors.
+ *
+ * This software is distributable under the BSD license. See the terms of the
+ * BSD license in the documentation provided with this software.
+ *
+ * http://www.opensource.org/licenses/bsd-license.php
+ */
+package jline.console.completer;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import static jline.internal.Preconditions.checkNotNull;
+
+/**
+ * Completer for a set of strings.
+ *
+ * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
+ * @since 2.3
+ */
+public class StringsCompleter
+        implements Completer
+{
+    private final SortedSet<String> strings = new TreeSet<String>();
+
+    public StringsCompleter() {
+        // empty
+    }
+
+    public StringsCompleter(final Collection<String> strings) {
+        checkNotNull(strings);
+        getStrings().addAll(strings);
+    }
+
+    public StringsCompleter(final String... strings) {
+        this(Arrays.asList(strings));
+    }
+
+    public Collection<String> getStrings() {
+        return strings;
+    }
+
+    public int complete(final String buffer, final int cursor, final List<CharSequence>
candidates) {
+        // buffer could be null
+        checkNotNull(candidates);
+
+        if (buffer == null) {
+            candidates.addAll(strings);
+        }
+        else {
+            for (String match : strings.tailSet(buffer)) {
+                if (!match.startsWith(buffer)) {
+                    break;
+                }
+
+                candidates.add(match);
+            }
+        }
+
+        return candidates.isEmpty() ? -1 : 0;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/a79f0211/shell/console/src/main/java/jline/internal/Preconditions.java
----------------------------------------------------------------------
diff --git a/shell/console/src/main/java/jline/internal/Preconditions.java b/shell/console/src/main/java/jline/internal/Preconditions.java
new file mode 100644
index 0000000..9bd27fd
--- /dev/null
+++ b/shell/console/src/main/java/jline/internal/Preconditions.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2002-2016, the original author or authors.
+ *
+ * This software is distributable under the BSD license. See the terms of the
+ * BSD license in the documentation provided with this software.
+ *
+ * http://www.opensource.org/licenses/bsd-license.php
+ */
+package jline.internal;
+
+// Some bits lifted from Guava's ( http://code.google.com/p/guava-libraries/ ) Preconditions.
+
+/**
+ * Preconditions.
+ *
+ * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
+ * @since 2.7
+ */
+public class Preconditions
+{
+    public static <T> T checkNotNull(final T reference) {
+        if (reference == null) {
+            throw new NullPointerException();
+        }
+        return reference;
+    }
+}
\ No newline at end of file


Mime
View raw message