felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1788155 - in /felix/trunk/gogo/jline: pom.xml src/main/java/org/apache/felix/gogo/jline/Posix.java
Date Wed, 22 Mar 2017 19:54:38 GMT
Author: gnodet
Date: Wed Mar 22 19:54:38 2017
New Revision: 1788155

URL: http://svn.apache.org/viewvc?rev=1788155&view=rev
Log:
[FELIX-5598][gogo][jline] Support the JLine ttop function if available

Modified:
    felix/trunk/gogo/jline/pom.xml
    felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Posix.java

Modified: felix/trunk/gogo/jline/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/pom.xml?rev=1788155&r1=1788154&r2=1788155&view=diff
==============================================================================
--- felix/trunk/gogo/jline/pom.xml (original)
+++ felix/trunk/gogo/jline/pom.xml Wed Mar 22 19:54:38 2017
@@ -54,7 +54,7 @@
         <dependency>
             <groupId>org.jline</groupId>
             <artifactId>jline</artifactId>
-            <version>3.0.0</version>
+            <version>3.2.0</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sshd</groupId>
@@ -78,6 +78,7 @@
                         <Import-Package>
                             !org.apache.felix.gogo.runtime.threadio,
                             org.apache.felix.service.*;version="[1.0,2.0)",
+                            org.jline*;version="[3.0,4)",
                             *
                         </Import-Package>
                         <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>

Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Posix.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Posix.java?rev=1788155&r1=1788154&r2=1788155&view=diff
==============================================================================
--- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Posix.java (original)
+++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Posix.java Wed Mar 22
19:54:38 2017
@@ -82,6 +82,7 @@ import org.jline.builtins.Options;
 import org.jline.builtins.Source;
 import org.jline.builtins.Source.PathSource;
 import org.jline.builtins.Source.StdInSource;
+import org.jline.builtins.TTop;
 import org.jline.terminal.Attributes;
 import org.jline.terminal.Terminal;
 import org.jline.utils.AttributedString;
@@ -98,12 +99,29 @@ import org.jline.utils.OSUtils;
  */
 public class Posix {
 
-    static final String[] functions = {
-            "cat", "echo", "grep", "sort", "sleep", "cd", "pwd", "ls",
-            "less", "watch", "nano", "tmux",
-            "head", "tail", "clear", "wc",
-            "date"
-    };
+    static final String[] functions;
+
+    static {
+        // TTop function is new in JLine 3.2
+        String[] func;
+        try {
+            Class cl = TTop.class;
+            func = new String[] {
+                    "cat", "echo", "grep", "sort", "sleep", "cd", "pwd", "ls",
+                    "less", "watch", "nano", "tmux",
+                    "head", "tail", "clear", "wc",
+                    "date", "ttop",
+            };
+        } catch (Throwable t) {
+            func = new String[] {
+                    "cat", "echo", "grep", "sort", "sleep", "cd", "pwd", "ls",
+                    "less", "watch", "nano", "tmux",
+                    "head", "tail", "clear", "wc",
+                    "date"
+            };
+        }
+        functions = func;
+    }
 
     public static final String DEFAULT_LS_COLORS = "dr=1;91:ex=1;92:sl=1;96:ot=34;43";
     public static final String DEFAULT_GREP_COLORS = "mt=1;31:fn=35:ln=32:se=36";
@@ -196,6 +214,9 @@ public class Posix {
             case "tmux":
                 tmux(session, process, argv);
                 break;
+            case "ttop":
+                ttop(session, process, argv);
+                break;
             case "clear":
                 clear(session, process, argv);
                 break;
@@ -797,6 +818,10 @@ public class Posix {
         }
     }
 
+    protected void ttop(final CommandSession session, Process process, String[] argv) throws
Exception {
+        TTop.ttop(Shell.getTerminal(session), process.out(), process.err(), argv);
+    }
+
     protected void nano(final CommandSession session, Process process, String[] argv) throws
Exception {
         final String[] usage = {
                 "nano -  edit files",



Mime
View raw message