You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/08/19 16:00:00 UTC
camel git commit: CAMEL-9541: Add karaf commands to show ascii docs
for components/dataformats/languages from the camel catalog
Repository: camel
Updated Branches:
refs/heads/master 4067f2a81 -> 58eb04a5c
CAMEL-9541: Add karaf commands to show ascii docs for components/dataformats/languages from the camel catalog
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/58eb04a5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/58eb04a5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/58eb04a5
Branch: refs/heads/master
Commit: 58eb04a5c70d9c6302b45c9315cc9e72c3678fdf
Parents: 4067f2a
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Aug 19 17:59:47 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Aug 19 17:59:47 2016 +0200
----------------------------------------------------------------------
.../camel/commands/AbstractCamelController.java | 14 ++++++
.../apache/camel/commands/CamelController.java | 24 +++++++++
.../commands/CatalogComponentDocCommand.java | 41 +++++++++++++++
.../commands/CatalogDataFormatDocCommand.java | 41 +++++++++++++++
.../commands/CatalogLanguageDocCommand.java | 41 +++++++++++++++
.../commands/catalog/CatalogComponentDoc.java | 36 +++++++++++++
.../commands/catalog/CatalogDataFormatDoc.java | 36 +++++++++++++
.../commands/catalog/CatalogLanguageDoc.java | 36 +++++++++++++
.../completers/ComponentListCompleter.java | 53 ++++++++++++++++++++
.../completers/DataFormatListCompleter.java | 53 ++++++++++++++++++++
.../completers/LanguageListCompleter.java | 53 ++++++++++++++++++++
.../blueprint/camel-commands-catalog.xml | 43 ++++++++++++++++
12 files changed, 471 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/58eb04a5/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
index 67b2746..f85f89c 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
@@ -489,4 +489,18 @@ public abstract class AbstractCamelController implements CamelController {
return answer;
}
+ @Override
+ public String catalogComponentAsciiDoc(String name) throws Exception {
+ return catalog.componentAsciiDoc(name);
+ }
+
+ @Override
+ public String catalogDataFormatAsciiDoc(String name) throws Exception {
+ return catalog.dataFormatAsciiDoc(name);
+ }
+
+ @Override
+ public String catalogLanguageAsciiDoc(String name) throws Exception {
+ return catalog.languageAsciiDoc(name);
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/58eb04a5/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
index a13b10f..b813909 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
@@ -344,4 +344,28 @@ public interface CamelController {
*/
Map<String, Set<String>> listLanguagesLabelCatalog() throws Exception;
+ /**
+ * Gets the component ascii documentation from the Camel catalog.
+ *
+ * @param name the name of the component
+ * @throws java.lang.Exception can be thrown
+ */
+ String catalogComponentAsciiDoc(String name) throws Exception;
+
+ /**
+ * Gets the data format ascii documentation from the Camel catalog.
+ *
+ * @param name the name of the data format
+ * @throws java.lang.Exception can be thrown
+ */
+ String catalogDataFormatAsciiDoc(String name) throws Exception;
+
+ /**
+ * Gets the language ascii documentation from the Camel catalog.
+ *
+ * @param name the name of the language
+ * @throws java.lang.Exception can be thrown
+ */
+ String catalogLanguageAsciiDoc(String name) throws Exception;
+
}
http://git-wip-us.apache.org/repos/asf/camel/blob/58eb04a5/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CatalogComponentDocCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CatalogComponentDocCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CatalogComponentDocCommand.java
new file mode 100644
index 0000000..f4ba47a
--- /dev/null
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CatalogComponentDocCommand.java
@@ -0,0 +1,41 @@
+/**
+ * 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.camel.commands;
+
+import java.io.PrintStream;
+
+/**
+ * Shows documentation of a component from Catalog
+ */
+public class CatalogComponentDocCommand extends AbstractCamelCommand {
+
+ private final String name;
+
+ public CatalogComponentDocCommand(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public Object execute(CamelController camelController, PrintStream out, PrintStream err) throws Exception {
+ String doc = camelController.catalogComponentAsciiDoc(name);
+ if (doc != null) {
+ out.println(doc);
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/58eb04a5/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CatalogDataFormatDocCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CatalogDataFormatDocCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CatalogDataFormatDocCommand.java
new file mode 100644
index 0000000..06d4256
--- /dev/null
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CatalogDataFormatDocCommand.java
@@ -0,0 +1,41 @@
+/**
+ * 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.camel.commands;
+
+import java.io.PrintStream;
+
+/**
+ * Shows documentation of a data format from Catalog
+ */
+public class CatalogDataFormatDocCommand extends AbstractCamelCommand {
+
+ private final String name;
+
+ public CatalogDataFormatDocCommand(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public Object execute(CamelController camelController, PrintStream out, PrintStream err) throws Exception {
+ String doc = camelController.catalogDataFormatAsciiDoc(name);
+ if (doc != null) {
+ out.println(doc);
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/58eb04a5/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CatalogLanguageDocCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CatalogLanguageDocCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CatalogLanguageDocCommand.java
new file mode 100644
index 0000000..ca891ea
--- /dev/null
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CatalogLanguageDocCommand.java
@@ -0,0 +1,41 @@
+/**
+ * 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.camel.commands;
+
+import java.io.PrintStream;
+
+/**
+ * Shows documentation of a language from Catalog
+ */
+public class CatalogLanguageDocCommand extends AbstractCamelCommand {
+
+ private final String name;
+
+ public CatalogLanguageDocCommand(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public Object execute(CamelController camelController, PrintStream out, PrintStream err) throws Exception {
+ String doc = camelController.catalogLanguageAsciiDoc(name);
+ if (doc != null) {
+ out.println(doc);
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/58eb04a5/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/CatalogComponentDoc.java
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/CatalogComponentDoc.java b/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/CatalogComponentDoc.java
new file mode 100644
index 0000000..10c6930
--- /dev/null
+++ b/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/CatalogComponentDoc.java
@@ -0,0 +1,36 @@
+/**
+ * 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.camel.karaf.commands.catalog;
+
+import org.apache.camel.commands.CamelCommand;
+import org.apache.camel.commands.CatalogComponentDocCommand;
+import org.apache.camel.karaf.commands.CamelCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+@Command(scope = "camel", name = "catalog-component-doc", description = "Show documentation about a Camel component from the Camel catalog")
+public class CatalogComponentDoc extends CamelCommandSupport {
+
+ @Argument(index = 0, name = "name", description = "The name of the Camel component.",
+ required = true, multiValued = false)
+ String name;
+
+ protected Object doExecute() throws Exception {
+ CamelCommand command = new CatalogComponentDocCommand(name);
+ return command.execute(camelController, System.out, System.err);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/58eb04a5/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/CatalogDataFormatDoc.java
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/CatalogDataFormatDoc.java b/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/CatalogDataFormatDoc.java
new file mode 100644
index 0000000..7498488
--- /dev/null
+++ b/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/CatalogDataFormatDoc.java
@@ -0,0 +1,36 @@
+/**
+ * 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.camel.karaf.commands.catalog;
+
+import org.apache.camel.commands.CamelCommand;
+import org.apache.camel.commands.CatalogDataFormatDocCommand;
+import org.apache.camel.karaf.commands.CamelCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+@Command(scope = "camel", name = "catalog-dataformat-doc", description = "Show documentation about a Camel data format from the Camel catalog")
+public class CatalogDataFormatDoc extends CamelCommandSupport {
+
+ @Argument(index = 0, name = "name", description = "The name of the Camel data format.",
+ required = true, multiValued = false)
+ String name;
+
+ protected Object doExecute() throws Exception {
+ CamelCommand command = new CatalogDataFormatDocCommand(name);
+ return command.execute(camelController, System.out, System.err);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/58eb04a5/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/CatalogLanguageDoc.java
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/CatalogLanguageDoc.java b/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/CatalogLanguageDoc.java
new file mode 100644
index 0000000..f873092
--- /dev/null
+++ b/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/CatalogLanguageDoc.java
@@ -0,0 +1,36 @@
+/**
+ * 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.camel.karaf.commands.catalog;
+
+import org.apache.camel.commands.CamelCommand;
+import org.apache.camel.commands.CatalogLanguageDocCommand;
+import org.apache.camel.karaf.commands.CamelCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+@Command(scope = "camel", name = "catalog-language-doc", description = "Show documentation about a Camel language from the Camel catalog")
+public class CatalogLanguageDoc extends CamelCommandSupport {
+
+ @Argument(index = 0, name = "name", description = "The name of the Camel language.",
+ required = true, multiValued = false)
+ String name;
+
+ protected Object doExecute() throws Exception {
+ CamelCommand command = new CatalogLanguageDocCommand(name);
+ return command.execute(camelController, System.out, System.err);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/58eb04a5/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/completers/ComponentListCompleter.java
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/completers/ComponentListCompleter.java b/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/completers/ComponentListCompleter.java
new file mode 100644
index 0000000..f5ba174
--- /dev/null
+++ b/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/completers/ComponentListCompleter.java
@@ -0,0 +1,53 @@
+/**
+ * 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.camel.karaf.commands.catalog.completers;
+
+import java.util.List;
+import java.util.Map;
+
+import jline.console.completer.StringsCompleter;
+import org.apache.camel.karaf.commands.completers.CamelCompleterSupport;
+
+public class ComponentListCompleter extends CamelCompleterSupport {
+
+ @Override
+ public int complete(String buffer, int cursor, List candidates) {
+ try {
+ StringsCompleter delegate = new StringsCompleter();
+ List<Map<String, String>> components = camelController.listComponentsCatalog(null);
+ for (Map<String, String> row : components) {
+ String name = row.get("name");
+ if (name != null) {
+ boolean match;
+ if (buffer == null || buffer.isEmpty()) {
+ match = true;
+ } else {
+ match = name.startsWith(buffer);
+ }
+ if (match) {
+ delegate.getStrings().add(name);
+ }
+ }
+ }
+ return delegate.complete(buffer, cursor, candidates);
+ } catch (Exception e) {
+ // nothing to do, no completion
+ }
+ return 0;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/58eb04a5/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/completers/DataFormatListCompleter.java
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/completers/DataFormatListCompleter.java b/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/completers/DataFormatListCompleter.java
new file mode 100644
index 0000000..71d1e94
--- /dev/null
+++ b/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/completers/DataFormatListCompleter.java
@@ -0,0 +1,53 @@
+/**
+ * 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.camel.karaf.commands.catalog.completers;
+
+import java.util.List;
+import java.util.Map;
+
+import jline.console.completer.StringsCompleter;
+import org.apache.camel.karaf.commands.completers.CamelCompleterSupport;
+
+public class DataFormatListCompleter extends CamelCompleterSupport {
+
+ @Override
+ public int complete(String buffer, int cursor, List candidates) {
+ try {
+ StringsCompleter delegate = new StringsCompleter();
+ List<Map<String, String>> dataFormats = camelController.listDataFormatsCatalog(null);
+ for (Map<String, String> row : dataFormats) {
+ String name = row.get("name");
+ if (name != null) {
+ boolean match;
+ if (buffer == null || buffer.isEmpty()) {
+ match = true;
+ } else {
+ match = name.startsWith(buffer);
+ }
+ if (match) {
+ delegate.getStrings().add(name);
+ }
+ }
+ }
+ return delegate.complete(buffer, cursor, candidates);
+ } catch (Exception e) {
+ // nothing to do, no completion
+ }
+ return 0;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/58eb04a5/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/completers/LanguageListCompleter.java
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/completers/LanguageListCompleter.java b/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/completers/LanguageListCompleter.java
new file mode 100644
index 0000000..423a79e
--- /dev/null
+++ b/platforms/karaf/commands-catalog/src/main/java/org/apache/camel/karaf/commands/catalog/completers/LanguageListCompleter.java
@@ -0,0 +1,53 @@
+/**
+ * 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.camel.karaf.commands.catalog.completers;
+
+import java.util.List;
+import java.util.Map;
+
+import jline.console.completer.StringsCompleter;
+import org.apache.camel.karaf.commands.completers.CamelCompleterSupport;
+
+public class LanguageListCompleter extends CamelCompleterSupport {
+
+ @Override
+ public int complete(String buffer, int cursor, List candidates) {
+ try {
+ StringsCompleter delegate = new StringsCompleter();
+ List<Map<String, String>> dataFormats = camelController.listLanguagesCatalog(null);
+ for (Map<String, String> row : dataFormats) {
+ String name = row.get("name");
+ if (name != null) {
+ boolean match;
+ if (buffer == null || buffer.isEmpty()) {
+ match = true;
+ } else {
+ match = name.startsWith(buffer);
+ }
+ if (match) {
+ delegate.getStrings().add(name);
+ }
+ }
+ }
+ return delegate.complete(buffer, cursor, candidates);
+ } catch (Exception e) {
+ // nothing to do, no completion
+ }
+ return 0;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/58eb04a5/platforms/karaf/commands-catalog/src/main/resources/OSGI-INF/blueprint/camel-commands-catalog.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands-catalog/src/main/resources/OSGI-INF/blueprint/camel-commands-catalog.xml b/platforms/karaf/commands-catalog/src/main/resources/OSGI-INF/blueprint/camel-commands-catalog.xml
index bad7f72..2198812 100644
--- a/platforms/karaf/commands-catalog/src/main/resources/OSGI-INF/blueprint/camel-commands-catalog.xml
+++ b/platforms/karaf/commands-catalog/src/main/resources/OSGI-INF/blueprint/camel-commands-catalog.xml
@@ -28,17 +28,48 @@
<action class="org.apache.camel.karaf.commands.catalog.CatalogComponentInfo">
<property name="camelController" ref="camelController"/>
</action>
+ <completers>
+ <ref component-id="componentCompleter"/>
+ <null/>
+ </completers>
+ </command>
+ <command name="camel-catalog/component-doc">
+ <action class="org.apache.camel.karaf.commands.catalog.CatalogComponentDoc">
+ <property name="camelController" ref="camelController"/>
+ </action>
+ <completers>
+ <ref component-id="componentCompleter"/>
+ <null/>
+ </completers>
</command>
<command name="camel-catalog/dataformat-list">
<action class="org.apache.camel.karaf.commands.catalog.CatalogDataFormatList">
<property name="camelController" ref="camelController"/>
</action>
</command>
+ <command name="camel-catalog/dataformat-doc">
+ <action class="org.apache.camel.karaf.commands.catalog.CatalogDataFormatDoc">
+ <property name="camelController" ref="camelController"/>
+ </action>
+ <completers>
+ <ref component-id="dataFormatCompleter"/>
+ <null/>
+ </completers>
+ </command>
<command name="camel-catalog/language-list">
<action class="org.apache.camel.karaf.commands.catalog.CatalogLanguageList">
<property name="camelController" ref="camelController"/>
</action>
</command>
+ <command name="camel-catalog/language-doc">
+ <action class="org.apache.camel.karaf.commands.catalog.CatalogLanguageDoc">
+ <property name="camelController" ref="camelController"/>
+ </action>
+ <completers>
+ <ref component-id="languageCompleter"/>
+ <null/>
+ </completers>
+ </command>
<command name="camel-catalog/eip-list">
<action class="org.apache.camel.karaf.commands.catalog.CatalogEipList">
<property name="camelController" ref="camelController"/>
@@ -50,4 +81,16 @@
<property name="bundleContext" ref="blueprintBundleContext"/>
</bean>
+ <bean id="componentCompleter" class="org.apache.camel.karaf.commands.catalog.completers.ComponentListCompleter">
+ <property name="camelController" ref="camelController"/>
+ </bean>
+
+ <bean id="dataFormatCompleter" class="org.apache.camel.karaf.commands.catalog.completers.DataFormatListCompleter">
+ <property name="camelController" ref="camelController"/>
+ </bean>
+
+ <bean id="languageCompleter" class="org.apache.camel.karaf.commands.catalog.completers.LanguageListCompleter">
+ <property name="camelController" ref="camelController"/>
+ </bean>
+
</blueprint>
\ No newline at end of file