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

<!--
  ~ Copyright The WildFly Authors
  ~ SPDX-License-Identifier: Apache-2.0
  -->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="urn:jboss:cli:1.0"
           targetNamespace="urn:jboss:cli:1.0"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
        >


    <xs:element name="jboss-cli">
        <xs:annotation>
            <xs:documentation>
                Root element for the JBoss Command Line Interface configuration.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="default-controller" minOccurs="0"/>
                <xs:element ref="history" minOccurs="0"/>
                <xs:element ref="ssl" minOccurs="0" maxOccurs="1"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
    <xs:element name="default-controller">
        <xs:annotation>
            <xs:documentation>
                This element contains the configuration of the default controller to connect to
                when the connect command is executed w/o arguments.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="host" type="xs:string" minOccurs="0" default="localhost"/>
                <xs:element name="port" type="xs:int" minOccurs="0" default="9999"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
    <xs:element name="history">
        <xs:annotation>
            <xs:documentation>
                This element contains the configuration for the commands and operations history log.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="enabled" type="xs:boolean" minOccurs="0" default="true"/>
                <xs:element name="file-name" type="xs:string" minOccurs="0" default=".jboss-cli-history"/>
                <xs:element name="file-dir" type="xs:string" minOccurs="0" default="${user.home}"/>
                <xs:element name="max-size" type="xs:int" minOccurs="0" default="500"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
    <xs:element name="ssl">
        <xs:annotation>
            <xs:documentation>
                This element contains the configuration for the Key and Trust stores
                used for SSL.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="keyStore" type="xs:string" minOccurs="0" />
                <xs:element name="keyStorePassword" type="xs:string" minOccurs="0" />
                <xs:element name="trustStore" type="xs:string" minOccurs="0" />
                <xs:element name="trustStorePassword" type="xs:string" minOccurs="0" />
                <xs:element name="modifyTrustStore" type="xs:boolean" default="true" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>
                            Setting to true will cause the CLI to prompt when unrecognised certificates are received
                            and allow them to be stored in the truststore.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
