karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [01/11] KARAF-2772 Extracting command-api
Date Mon, 24 Feb 2014 10:27:59 GMT
Repository: karaf
Updated Branches:
  refs/heads/command-api [created] 1ee78df92


http://git-wip-us.apache.org/repos/asf/karaf/blob/1ee78df9/shell/console/src/test/java/org/apache/karaf/shell/console/completer/BooleanCompleterTest.java
----------------------------------------------------------------------
diff --git a/shell/console/src/test/java/org/apache/karaf/shell/console/completer/BooleanCompleterTest.java
b/shell/console/src/test/java/org/apache/karaf/shell/console/completer/BooleanCompleterTest.java
deleted file mode 100644
index 7cbf05c..0000000
--- a/shell/console/src/test/java/org/apache/karaf/shell/console/completer/BooleanCompleterTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.shell.console.completer;
-
-import org.apache.karaf.shell.commands.Action;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.basic.SimpleCommand;
-import org.apache.felix.service.command.CommandSession;
-import org.apache.karaf.shell.console.Completer;
-import org.junit.Test;
-
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-
-public class BooleanCompleterTest extends CompleterTestSupport {
-
-    @Test
-    public void testCompleteArgumnets() throws Exception {
-        CommandSession session = new DummyCommandSession();
-        Completer comp = new ArgumentCompleter(session, new SimpleCommand(MyAction.class),
"my:action");
-
-        // arg 0
-        assertEquals(Arrays.asList("true "), complete(comp, "action t"));
-        assertEquals(Arrays.asList("false "), complete(comp, "action f"));
-
-        // arg 1
-        assertEquals(Arrays.asList("true "), complete(comp, "action false t"));
-        assertEquals(Arrays.asList("false "), complete(comp, "action true f"));
-
-        // unknown args
-        assertEquals(Arrays.asList(), complete(comp, "action c"));
-        assertEquals(Arrays.asList(), complete(comp, "action true true a"));
-    }
-
-    public static class MyAction implements Action {
-        @Argument(index = 0)
-        Boolean foo;
-        @Argument(index = 1)
-        boolean bar;
-
-        public Object execute(CommandSession session) throws Exception {
-            return null;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/1ee78df9/shell/console/src/test/java/org/apache/karaf/shell/console/completer/CompleterTestSupport.java
----------------------------------------------------------------------
diff --git a/shell/console/src/test/java/org/apache/karaf/shell/console/completer/CompleterTestSupport.java
b/shell/console/src/test/java/org/apache/karaf/shell/console/completer/CompleterTestSupport.java
deleted file mode 100644
index e5341a5..0000000
--- a/shell/console/src/test/java/org/apache/karaf/shell/console/completer/CompleterTestSupport.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.shell.console.completer;
-
-import org.apache.karaf.shell.console.Completer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Useful base class for completion related test cases
- */
-public abstract class CompleterTestSupport {
-    protected List<String> complete(Completer completer, String buf) {
-        List<String> candidates = new ArrayList<String>();
-        completer.complete(buf, buf.length(), candidates);
-        return candidates;
-    }
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/1ee78df9/shell/console/src/test/java/org/apache/karaf/shell/console/completer/CompleterValuesTest.java
----------------------------------------------------------------------
diff --git a/shell/console/src/test/java/org/apache/karaf/shell/console/completer/CompleterValuesTest.java
b/shell/console/src/test/java/org/apache/karaf/shell/console/completer/CompleterValuesTest.java
deleted file mode 100644
index 2ec4a81..0000000
--- a/shell/console/src/test/java/org/apache/karaf/shell/console/completer/CompleterValuesTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.shell.console.completer;
-
-import org.apache.karaf.shell.commands.Action;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.CompleterValues;
-import org.apache.karaf.shell.commands.basic.SimpleCommand;
-import org.apache.felix.service.command.CommandSession;
-import org.apache.karaf.shell.console.Completer;
-import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-public class CompleterValuesTest extends CompleterTestSupport {
-
-    @Test
-    public void testCompleteArgumnets() throws Exception {
-        CommandSession session = new DummyCommandSession();
-        Completer comp = new ArgumentCompleter(session, new SimpleCommand(MyAction.class),
"my:action");
-
-        // arg 0
-        assertEquals(Arrays.asList("a1", "a2", "a3"), complete(comp, "action a"));
-        assertEquals(Arrays.asList("b4", "b5"), complete(comp, "action b"));
-
-        // arg 1
-        assertEquals(Arrays.asList("c2", "c3"), complete(comp, "action a1 c"));
-        assertEquals(Arrays.asList("d5", "d6", "d7"), complete(comp, "action b4 d"));
-
-        // unknown args
-        assertEquals(Arrays.asList(), complete(comp, "action c"));
-        assertEquals(Arrays.asList(), complete(comp, "action a1 d5 a"));
-    }
-
-    public static class MyAction implements Action {
-        @Argument(index = 0)
-        String foo;
-        @Argument(index = 1)
-        String bar;
-
-        public Object execute(CommandSession session) throws Exception {
-            return null;
-        }
-
-        @CompleterValues(index = 0)
-        public String[] getFooValues() {
-            return new String[]{"a1", "a2", "a3", "b4", "b5"};
-        }
-
-        @CompleterValues(index = 1)
-        public List<String> getBarValues() {
-            return Arrays.asList("c2", "c3", "d5", "d6", "d7");
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/1ee78df9/shell/console/src/test/java/org/apache/karaf/shell/console/completer/CompletionTest.java
----------------------------------------------------------------------
diff --git a/shell/console/src/test/java/org/apache/karaf/shell/console/completer/CompletionTest.java
b/shell/console/src/test/java/org/apache/karaf/shell/console/completer/CompletionTest.java
deleted file mode 100644
index 25d0485..0000000
--- a/shell/console/src/test/java/org/apache/karaf/shell/console/completer/CompletionTest.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.shell.console.completer;
-
-import java.util.Arrays;
-
-import org.apache.felix.service.command.CommandSession;
-import org.apache.karaf.shell.commands.Action;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.commands.basic.Context;
-import org.apache.karaf.shell.commands.basic.SimpleCommand;
-import org.apache.karaf.shell.commands.basic.SimpleSubShell;
-import org.apache.karaf.shell.console.CommandSessionHolder;
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.console.ExitAction;
-import org.apache.karaf.shell.console.SessionProperties;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class CompletionTest extends CompleterTestSupport {
-
-    @Test
-    public void testSubShellCompletion() throws Exception {
-        Context context = new Context();
-        context.set("SCOPE", "*");
-        context.set(SessionProperties.COMPLETION_MODE, "subshell");
-        CommandSessionHolder.setSession(context.getSession());
-
-        context.addCommand("*", new SimpleSubShell("foo"), "foo");
-        context.addCommand("*", new SimpleCommand(ExitAction.class), "exit");
-        context.addCommand("foo", new SimpleCommand(MyAction.class), "my-action");
-        context.addCommand("foo", new SimpleCommand(MyActionTwoArguments.class), "one-action");
-        context.addCommand("bar", new SimpleCommand(MyAction.class), "one-action");
-        context.addCommand("bar", new SimpleCommand(MyActionTwoArguments.class), "another");
-
-        Completer comp = new CommandsCompleter(context.getSession());
-
-        context.execute("foo");
-        assertEquals(Arrays.asList("my-action "), complete(comp, "my"));
-        assertEquals(Arrays.asList("exit ", "my-action ", "one-action "), complete(comp,
""));
-        assertEquals(Arrays.asList(), complete(comp, "an"));
-        assertEquals(Arrays.asList("--check", "--foo", "--help", "--integer", "--string"),
-                     complete(comp, "my-action --"));
-        assertEquals(Arrays.asList("--dummy", "--help"), complete(comp, "one-action --"));
-
-        context.execute("exit");
-        assertEquals(Arrays.asList(), complete(comp, "my"));
-        assertEquals(Arrays.asList("exit ", "foo "), complete(comp, ""));
-        assertEquals(Arrays.asList(), complete(comp, "an"));
-    }
-
-    @Test
-    public void testFirstCompletion() throws Exception {
-        Context context = new Context();
-        context.set("SCOPE", "*");
-        context.set(SessionProperties.COMPLETION_MODE, "first");
-        CommandSessionHolder.setSession(context.getSession());
-
-        context.addCommand("*", new SimpleSubShell("foo"), "foo");
-        context.addCommand("*", new SimpleCommand(ExitAction.class), "exit");
-        context.addCommand("foo", new SimpleCommand(MyAction.class), "my-action");
-        context.addCommand("foo", new SimpleCommand(MyActionTwoArguments.class), "one-action");
-        context.addCommand("bar", new SimpleCommand(MyAction.class), "one-action");
-        context.addCommand("bar", new SimpleCommand(MyActionTwoArguments.class), "another");
-
-        Completer comp = new CommandsCompleter(context.getSession());
-
-        context.execute("foo");
-        assertEquals(Arrays.asList("my-action "), complete(comp, "my"));
-        assertEquals(Arrays.asList("my-action ", "one-action "), complete(comp, ""));
-        assertEquals(Arrays.asList("another "), complete(comp, "an"));
-        assertEquals(Arrays.asList("--check", "--foo", "--help", "--integer", "--string"),
-                     complete(comp, "my-action --"));
-        assertEquals(Arrays.asList("--dummy", "--help"), complete(comp, "one-action --"));
-
-        context.execute("exit");
-        assertEquals(Arrays.asList("my-action "), complete(comp, "my"));
-        assertEquals(Arrays.asList("*:exit", "*:foo", "another", "bar:another",
-                                   "bar:one-action", "exit", "foo",
-                                   "foo:my-action", "foo:one-action", "my-action",
-                                   "one-action", "one-action"), complete(comp, ""));
-        assertEquals(Arrays.asList("another "), complete(comp, "an"));
-    }
-
-    @Test
-    public void testGlobalCompletion() throws Exception {
-        Context context = new Context();
-        context.set("SCOPE", "*");
-        context.set(SessionProperties.COMPLETION_MODE, "global");
-        CommandSessionHolder.setSession(context.getSession());
-
-        context.addCommand("*", new SimpleSubShell("foo"), "foo");
-        context.addCommand("*", new SimpleCommand(ExitAction.class), "exit");
-        context.addCommand("foo", new SimpleCommand(MyAction.class), "my-action");
-        context.addCommand("foo", new SimpleCommand(MyActionTwoArguments.class), "one-action");
-        context.addCommand("bar", new SimpleCommand(MyAction.class), "one-action");
-        context.addCommand("bar", new SimpleCommand(MyActionTwoArguments.class), "another");
-
-        Completer comp = new CommandsCompleter(context.getSession());
-
-        context.execute("foo");
-        assertEquals(Arrays.asList("my-action "), complete(comp, "my"));
-        assertEquals(Arrays.asList("*:exit", "*:foo", "another", "bar:another",
-                                    "bar:one-action", "exit", "foo",
-                                   "foo:my-action", "foo:one-action", "my-action",
-                                   "one-action", "one-action"), complete(comp, ""));
-        assertEquals(Arrays.asList("another "), complete(comp, "an"));
-        assertEquals(Arrays.asList("--check", "--foo", "--help", "--integer", "--string"),
-                     complete(comp, "my-action --"));
-        assertEquals(Arrays.asList("--dummy", "--help"), complete(comp, "one-action --"));
-
-        context.execute("exit");
-        assertEquals(Arrays.asList("my-action "), complete(comp, "my"));
-        assertEquals(Arrays.asList("*:exit", "*:foo", "another", "bar:another",
-                                   "bar:one-action", "exit", "foo",
-                                   "foo:my-action", "foo:one-action", "my-action",
-                                   "one-action", "one-action"), complete(comp, ""));
-        assertEquals(Arrays.asList("another "), complete(comp, "an"));
-    }
-
-    public static class MyAction implements Action {
-        @Option(name = "-f", aliases = { "--foo" })
-        int f;
-
-        @Option(name = "-c", aliases = "--check")
-        boolean check;
-
-        @Option(name = "-s", aliases = "--string")
-        String string;
-
-        @Option(name = "-i", aliases = "--integer")
-        String integer;
-
-        public Object execute(CommandSession session) throws Exception {
-            return null;
-        }
-    }
-
-    public static class MyActionTwoArguments implements Action {
-
-        @Option(name = "--dummy")
-        boolean dummy;
-
-        @Argument(index = 0, name = "one", description = "one description", required = true,
multiValued = false)
-        private String one;
-
-        @Argument(index = 1, name = "two", description = "two description", required = true,
multiValued = false)
-        private String two;
-
-        public Object execute(CommandSession session) throws Exception {
-            return null;
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/1ee78df9/shell/console/src/test/java/org/apache/karaf/shell/console/completer/DummyCommandSession.java
----------------------------------------------------------------------
diff --git a/shell/console/src/test/java/org/apache/karaf/shell/console/completer/DummyCommandSession.java
b/shell/console/src/test/java/org/apache/karaf/shell/console/completer/DummyCommandSession.java
deleted file mode 100644
index ac1a894..0000000
--- a/shell/console/src/test/java/org/apache/karaf/shell/console/completer/DummyCommandSession.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.shell.console.completer;
-
-import java.io.InputStream;
-import java.io.PrintStream;
-
-import org.apache.felix.service.command.CommandSession;
-
-public class DummyCommandSession implements CommandSession {
-    public Object convert(Class<?> type, Object instance) {
-        return null;
-    }
-    public CharSequence format(Object target, int level) {
-        return null;
-    }
-    public void put(String name, Object value) {
-    }
-    public Object get(String name) {
-        return null;
-    }
-    public PrintStream getConsole() {
-        return null;
-    }
-    public InputStream getKeyboard() {
-        return null;
-    }
-    public void close() {
-    }
-    public Object execute(CharSequence commandline) throws Exception {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/1ee78df9/shell/console/src/test/java/org/apache/karaf/shell/console/completer/FileCompleterTest.java
----------------------------------------------------------------------
diff --git a/shell/console/src/test/java/org/apache/karaf/shell/console/completer/FileCompleterTest.java
b/shell/console/src/test/java/org/apache/karaf/shell/console/completer/FileCompleterTest.java
deleted file mode 100644
index 0405371..0000000
--- a/shell/console/src/test/java/org/apache/karaf/shell/console/completer/FileCompleterTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.shell.console.completer;
-
-import java.io.File;
-import java.util.Arrays;
-
-import org.apache.karaf.shell.commands.Action;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.basic.SimpleCommand;
-import org.apache.felix.service.command.CommandSession;
-import org.apache.karaf.shell.console.Completer;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class FileCompleterTest extends CompleterTestSupport {
-
-    @Test
-    public void testCompleteArgumnets() throws Exception {
-        CommandSession session = new DummyCommandSession();
-        Completer comp = new ArgumentCompleter(session, new SimpleCommand(MyAction.class),
"my:action");
-
-        // arg 0
-        assertEquals(Arrays.asList("src"+File.separator), complete(comp, "action s"));
-        assertEquals(Arrays.asList("main"+File.separator), complete(comp, "action src/m"));
-        assertEquals(Arrays.asList("java"+File.separator), complete(comp, "action src/main/j"));
-    }
-
-    public static class MyAction implements Action {
-        @Argument(index = 0)
-        File foo;
-        @Argument(index = 1)
-        File bar;
-
-        public Object execute(CommandSession session) throws Exception {
-            return null;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/1ee78df9/shell/help/pom.xml
----------------------------------------------------------------------
diff --git a/shell/help/pom.xml b/shell/help/pom.xml
index 2bb514e..3870f36 100644
--- a/shell/help/pom.xml
+++ b/shell/help/pom.xml
@@ -39,17 +39,12 @@
 
     <dependencies>
         <dependency>
-            <groupId>org.fusesource.jansi</groupId>
-            <artifactId>jansi</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.karaf.shell</groupId>
             <artifactId>org.apache.karaf.shell.table</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.karaf.shell</groupId>
-            <artifactId>org.apache.karaf.shell.console</artifactId>
+            <artifactId>org.apache.karaf.shell.command.api</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.felix</groupId>

http://git-wip-us.apache.org/repos/asf/karaf/blob/1ee78df9/shell/help/src/main/java/org/apache/karaf/shell/help/impl/CommandListHelpProvider.java
----------------------------------------------------------------------
diff --git a/shell/help/src/main/java/org/apache/karaf/shell/help/impl/CommandListHelpProvider.java
b/shell/help/src/main/java/org/apache/karaf/shell/help/impl/CommandListHelpProvider.java
index 98102c4..6df6c9f 100644
--- a/shell/help/src/main/java/org/apache/karaf/shell/help/impl/CommandListHelpProvider.java
+++ b/shell/help/src/main/java/org/apache/karaf/shell/help/impl/CommandListHelpProvider.java
@@ -25,21 +25,17 @@ import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
-import jline.Terminal;
-
 import org.apache.felix.gogo.commands.Action;
 import org.apache.felix.service.command.CommandSession;
 import org.apache.felix.service.command.Function;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.commands.CommandWithAction;
-import org.apache.karaf.shell.commands.basic.AbstractCommand;
 import org.apache.karaf.shell.commands.meta.ActionMetaDataFactory;
 import org.apache.karaf.shell.console.HelpProvider;
 import org.apache.karaf.shell.console.NameScoping;
 import org.apache.karaf.shell.console.SessionProperties;
 import org.apache.karaf.shell.table.Col;
 import org.apache.karaf.shell.table.ShellTable;
-import org.fusesource.jansi.Ansi;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 
@@ -113,10 +109,8 @@ public class CommandListHelpProvider implements HelpProvider {
     }
 
     protected void printMethodList(CommandSession session, PrintStream out, SortedMap<String,
String> commands) {
-        Terminal term = (Terminal) session.get(".jline.terminal");
-        int termWidth = term != null ? term.getWidth() : 80;
-        out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("COMMANDS").a(Ansi.Attribute.RESET));
-        ShellTable table = new ShellTable().noHeaders().separator(" ").size(termWidth);
+        out.println("COMMANDS");
+        ShellTable table = new ShellTable().noHeaders().separator(" ").size(getWidth(session));
         table.column(new Col("Command").maxSize(35));
         table.column(new Col("Description"));
         for (Map.Entry<String,String> entry : commands.entrySet()) {
@@ -126,6 +120,11 @@ public class CommandListHelpProvider implements HelpProvider {
         table.print(out, true);
     }
     
+    private int getWidth(CommandSession session) {
+        Object cols = session.get("COLUMNS");
+        return  (cols != null && cols instanceof Integer) ? (Integer)cols : 80;
+    }
+    
     protected Function unProxy(Function function) {
         try {
             if (function.getClass().getName().contains("CommandProxy")) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/1ee78df9/shell/pom.xml
----------------------------------------------------------------------
diff --git a/shell/pom.xml b/shell/pom.xml
index d8dc873..68dd0e8 100644
--- a/shell/pom.xml
+++ b/shell/pom.xml
@@ -34,6 +34,7 @@
     <name>Apache Karaf :: Shell</name>
 
     <modules>
+        <module>command-api</module>
         <module>commands</module>
         <module>console</module>
         <module>ssh</module>


Mime
View raw message