<?xml version="1.0" encoding="UTF-8"?>
<!--

    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.

-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">

   	<bean id="commandCompleter" class="org.apache.karaf.shell.console.completer.CommandsCompleter"/>

    <service>
        <interfaces>
            <value>org.apache.felix.service.command.Function</value>
            <value>org.apache.karaf.shell.console.CompletableFunction</value>
        </interfaces>
        <service-properties>
            <entry key="osgi.command.scope" value="*"/>
            <entry key="osgi.command.function" value="help"/>
        </service-properties>
        <bean class="org.apache.karaf.shell.console.commands.BlueprintCommand">
            <property name="blueprintContainer" ref="blueprintContainer"/>
            <property name="blueprintConverter" ref="blueprintConverter"/>
            <property name="actionId" value="help"/>
            <property name="completers">
                <list>
                    <bean class="org.apache.karaf.shell.console.completer.CommandNamesCompleter"/>
                </list>
            </property>
        </bean>
    </service>

    <bean id="help" class="org.apache.karaf.shell.help.impl.HelpAction" activation="lazy" scope="prototype">
        <property name="provider" ref="helpSystem"/>
    </bean>
    
    <bean id="helpSystem" class="org.apache.karaf.shell.help.impl.HelpSystem">
        <argument ref="blueprintBundleContext"/>
    </bean>

    <!--use to get the help on the list of commands -->
    <service interface="org.apache.karaf.shell.console.HelpProvider" ranking="-20">
        <bean class="org.apache.karaf.shell.help.impl.CommandListHelpProvider" />
    </service>

    <!-- use for "help command" syntax -->
    <reference id="threadIO" interface="org.apache.felix.service.threadio.ThreadIO"/>
    <service auto-export="interfaces" ranking="-10">
        <bean class="org.apache.karaf.shell.help.impl.SingleCommandHelpProvider">
            <argument ref="threadIO" />
        </bean>
    </service>

    <!-- use for "help" to get help on each command in the commands list -->
    <service auto-export="interfaces" ranking="-5">
        <bean class="org.apache.karaf.shell.help.impl.SimpleHelpProvider">
            <property name="help">
                <map>
                    <entry key="%root%"><value><![CDATA[${command-list|}]]></value></entry>
                    <entry key="all"><value><![CDATA[${command-list|}]]></value></entry>
                </map>
            </property>
        </bean>
    </service>
 
</blueprint>
