Does clispec support grouping option

Hi,
Like yang supports grouping, does clispec also has any similar feature?

Thanks
Phani

There is no support of the YANG grouping feature in clispec.

Clispec is just XML. For reuse, you can use anything which allows reuse and can generate XML.

If you know Groovy language, you can use e.g. MarkupBuilder or StreamingMarkupBuilder. Example of reusable"blocks" can be found here.
(There is also yangbuilder that allows similar reuse approach in YANG.)

Here is a sample code that makes clispec skeleton

static private String indentXml(def xml, def indent) {
    def factory = TransformerFactory.newInstance()
    try {
        factory.setAttribute("indent-number", indent);
    } catch (IllegalArgumentException iae) {
        println "XML indent-number not supported by the JDK, xml/clispec will not be indented!"
    }

    Transformer transformer = factory.newTransformer()
    transformer.setOutputProperty(OutputKeys.INDENT, 'yes')
    StreamResult result = new StreamResult(new StringWriter())
    transformer.transform(new StreamSource(new ByteArrayInputStream(xml.toString().bytes)), result)
    return result.writer.toString()
}

static private def makeCliCommon() {
    return {
        modifications {
            hide(src: "show jobs")
            hide(src: "show notification")
            hide(src: "show parser")
            hide(src: "xpath")
            hide(src: "job")
            hide(src: "prompt1")
            hide(src: "prompt2")
        }
}

// .... add other blocks like  makeIsis, ...

// build clispec (XML)
def builder = new StreamingMarkupBuilder();
def xml = builder.bind {
    mkp.declareAlias(anyTag: 'any') // 'any' is a standard method in Groovy
    clispec(xmlns: 'http://tail-f.com/ns/clispec/1.0', style: 'c') {
        comment << "CLI - generated by Builder/Clispec generator"
        operationalMode {
            if (protocol in [common, isis, lacp, stp]) {
                switch (protocol) {
                    case common:
                        out << makeCliCommon()
                        break
                    case isis:
                        out << makeIsis()
                        break                   
                    case lacp:
                        out << makeLacp()
                        break
                    case stp:
                        out << makeStp()
                        break
                }
            }
            if (protocol in [rtm, bgp, ospf]) {
                cmd(name: "ip", mount: "show") {                  
                    switch (protocol) {
                        case rtm:
                            out << makeRtm()
                            break
                        case bgp:
                            out << makeBgp()
                            break
                        case ospf:
                            out << makeOspf()
                            break
                    }
                }
            }
        }
    }
}
out = indentXml(xml, 4)

You can also use Python to generate XML or any other (scripting) language.

Hi,
Thanks for the reply. This idea is useful for us, in managing the complexity .

Thanks
Phani